int main(int argc, char **argv){ int order; printf("How many random numbers: 10^"); scanf("%d",&order); int size =(int)pow(10,order); double* heap = calloc(size,sizeof(double*)); srand(time(NULL)); for(int i = 1; i<size ;i++){ double R =(rand()/(RAND_MAX+1.0)); heap[i] = R; //printf("%f\n",R); } heapsort(heap,size); for(int i = 1; i<6 ;i++){ printf("%f \n",heap[i] ); } printf(".........\n"); for(int i = size-7; i<size-1 ;i++){ printf("%f \n",heap[i] ); } bisection(.7,heap,size,0); printf("Number of operations: "); num_ops(); return 0; }
static inline void collect_regs( unsigned long *regs, instr_t *instr, int (*num_ops)(instr_t *), opnd_t (*get_op)(instr_t *, uint) ) { int i; opnd_t opnd; // make sure these regs are always seen as "used" *regs |= (1 << DR_REG_NULL); for(i=0; i < num_ops(instr); i++) { opnd = get_op(instr, i); if(opnd_is_reg(opnd)) { collect_reg(regs, opnd_get_reg(opnd)); } else if(opnd_is_base_disp(opnd)) { collect_reg(regs, opnd_get_base(opnd)); collect_reg(regs, opnd_get_index(opnd)); } } collect_reg(regs, DR_REG_RSP); collect_reg(regs, DR_REG_RBP); collect_reg(regs, DR_REG_RAX); collect_reg(regs, DR_REG_RDX); }
static bool contains_ptrtype(const Type* type) { switch (type->tag()) { case Node_PtrType: return false; case Node_IndefiniteArrayType: return contains_ptrtype(type->as<ArrayType>()->elem_type()); case Node_DefiniteArrayType: return contains_ptrtype(type->as<DefiniteArrayType>()->elem_type()); case Node_FnType: return false; case Node_StructType: { bool good = true; auto struct_type = type->as<StructType>(); for (size_t i = 0, e = struct_type->num_ops(); i != e; ++i) good &= contains_ptrtype(struct_type->op(i)); return good; } case Node_TupleType: { bool good = true; auto tuple = type->as<TupleType>(); for (size_t i = 0, e = tuple->num_ops(); i != e; ++i) good &= contains_ptrtype(tuple->op(i)); return good; } default: return true; } }