#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int adjust_rep_count(int, double, double, double);
int /*<<< orphan*/ integral_gen(int, int, double *);
int /*<<< orphan*/ integral_recur(int, int, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ timer_start();
double timer_stop();
int main(void) {
  int nminn = 0;
  int nmaxx = 100;
  double vals1[100 + 1], vals2[100 + 1];
  integral_recur(nminn, nmaxx, vals1);
  integral_gen(nminn, nmaxx, vals2);
  for (int i = 0, j = nminn; i <= nmaxx - nminn; i++, j++) {
    printf("%.18f\t%.18f\t%d\n", vals1[i], vals2[i], j);
  }
  int count = 10;
  double time;
  double time1;
  double tmin = 1;
  double tmax = 2;
  printf("integral_recur\n");
  do {
    timer_start();
    for (int k = 0; k <= count; k++) {
      integral_recur(nminn, nmaxx, vals1);
    }
    time = timer_stop();
    time1 = time / count;
    printf(" %10.2f usec     %10.6f sec    %10d\n", time1 * 1.e6, time, count);
    count = adjust_rep_count(count, time, tmin, tmax);
  } while ((time > tmax) || (time < tmin));
  printf("integral_gen\n");
  count = 10;
  do {
    timer_start();
    for (int k = 0; k <= count; k++) {
      integral_gen(nminn, nmaxx, vals2);
    }
    time = timer_stop();
    time1 = time / count;
    printf(" %10.2f usec     %10.6f sec    %10d\n", time1 * 1.e6, time, count);
    count = adjust_rep_count(count, time, tmin, tmax);
  } while ((time > tmax) || (time < tmin));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x340(%rbp),%rdx
call   1050 <integral_recur@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x670(%rbp),%rdx
call   1060 <integral_gen@plt>
movl   $0x0,-0x674(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x678(%rbp)
mov    -0x674(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     1222 <main+0xc2>
movslq -0x674(%rbp),%rax
movsd  -0x340(%rbp,%rax,8),%xmm0
ff ff
movslq -0x674(%rbp),%rax
movsd  -0x670(%rbp,%rax,8),%xmm1
ff ff
mov    -0x678(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x674(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x674(%rbp)
mov    -0x678(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x678(%rbp)
jmp    11b7 <main+0x57>
movl   $0xa,-0x67c(%rbp)
movsd  0xdd4(%rip),%xmm0
movsd  %xmm0,-0x698(%rbp)
ff
movsd  0xdbc(%rip),%xmm0
movsd  %xmm0,-0x6a0(%rbp)
ff
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <timer_start@plt>
movl   $0x0,-0x6a4(%rbp)
mov    -0x6a4(%rbp),%eax
cmp    -0x67c(%rbp),%eax
jg     12a3 <main+0x143>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x340(%rbp),%rdx
call   1050 <integral_recur@plt>
mov    -0x6a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a4(%rbp)
jmp    126b <main+0x10b>
mov    $0x0,%al
call   1070 <timer_stop@plt>
movsd  %xmm0,-0x688(%rbp)
ff
movsd  -0x688(%rbp),%xmm0
ff
cvtsi2sdl -0x67c(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x690(%rbp)
ff
movsd  0xd3a(%rip),%xmm0
mulsd  -0x690(%rbp),%xmm0
ff
movsd  -0x688(%rbp),%xmm1
ff
mov    -0x67c(%rbp),%esi
lea    0xd45(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x67c(%rbp),%edi
movsd  -0x688(%rbp),%xmm0
ff
movsd  -0x698(%rbp),%xmm1
ff
movsd  -0x6a0(%rbp),%xmm2
ff
call   1030 <adjust_rep_count@plt>
mov    %eax,-0x67c(%rbp)
movsd  -0x688(%rbp),%xmm0
ff
mov    $0x1,%al
ucomisd -0x6a0(%rbp),%xmm0
ff
mov    %al,-0x6a9(%rbp)
ja     135e <main+0x1fe>
movsd  -0x688(%rbp),%xmm1
ff
movsd  -0x698(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x6a9(%rbp)
mov    -0x6a9(%rbp),%al
test   $0x1,%al
jne    125a <main+0xfa>
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xa,-0x67c(%rbp)
mov    $0x0,%al
call   1080 <timer_start@plt>
movl   $0x0,-0x6a8(%rbp)
mov    -0x6a8(%rbp),%eax
cmp    -0x67c(%rbp),%eax
jg     13cd <main+0x26d>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x670(%rbp),%rdx
call   1060 <integral_gen@plt>
mov    -0x6a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6a8(%rbp)
jmp    1395 <main+0x235>
mov    $0x0,%al
call   1070 <timer_stop@plt>
movsd  %xmm0,-0x688(%rbp)
ff
movsd  -0x688(%rbp),%xmm0
ff
cvtsi2sdl -0x67c(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x690(%rbp)
ff
movsd  0xc10(%rip),%xmm0
mulsd  -0x690(%rbp),%xmm0
ff
movsd  -0x688(%rbp),%xmm1
ff
mov    -0x67c(%rbp),%esi
lea    0xc1b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x67c(%rbp),%edi
movsd  -0x688(%rbp),%xmm0
ff
movsd  -0x698(%rbp),%xmm1
ff
movsd  -0x6a0(%rbp),%xmm2
ff
call   1030 <adjust_rep_count@plt>
mov    %eax,-0x67c(%rbp)
movsd  -0x688(%rbp),%xmm0
ff
mov    $0x1,%al
ucomisd -0x6a0(%rbp),%xmm0
ff
mov    %al,-0x6aa(%rbp)
ja     1488 <main+0x328>
movsd  -0x688(%rbp),%xmm1
ff
movsd  -0x698(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x6aa(%rbp)
mov    -0x6aa(%rbp),%al
test   $0x1,%al
jne    1384 <main+0x224>
xor    %eax,%eax
add    $0x6b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x668,%rsp
xor    %ebx,%ebx
lea    0x340(%rsp),%rdx
xor    %edi,%edi
mov    $0x64,%esi
call   1060 <integral_recur@plt>
lea    0x10(%rsp),%rdx
xor    %edi,%edi
mov    $0x64,%esi
call   1070 <integral_gen@plt>
lea    0xe6d(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  0x340(%rsp,%rbx,8),%xmm0
movsd  0x10(%rsp,%rbx,8),%xmm1
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x65,%rbx
jne    11b0 <main+0x40>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%r15d
lea    0xe3a(%rip),%r14
lea    0x340(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <timer_start@plt>
test   %r15d,%r15d
js     1224 <main+0xb4>
lea    0x1(%r15),%ebp
xor    %edi,%edi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <integral_recur@plt>
add    $0xffffffff,%ebp
jne    1210 <main+0xa0>
xor    %eax,%eax
call   1080 <timer_stop@plt>
movapd %xmm0,%xmm2
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xdb7(%rip),%xmm0
mov    %r14,%rdi
movapd %xmm2,%xmm1
mov    %r15d,%esi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r15d,%edi
movsd  0x8(%rsp),%xmm0
movsd  0xd9d(%rip),%xmm1
movsd  0xd9d(%rip),%xmm2
call   1040 <adjust_rep_count@plt>
movsd  0x8(%rsp),%xmm1
mov    %eax,%r15d
ucomisd 0xd87(%rip),%xmm1
ja     1200 <main+0x90>
movsd  0xd71(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1200 <main+0x90>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%r15d
lea    0xd6e(%rip),%r14
lea    0x10(%rsp),%rbx
nop
xor    %eax,%eax
call   1090 <timer_start@plt>
test   %r15d,%r15d
js     12e4 <main+0x174>
lea    0x1(%r15),%ebp
xor    %edi,%edi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1070 <integral_gen@plt>
add    $0xffffffff,%ebp
jne    12d0 <main+0x160>
xor    %eax,%eax
call   1080 <timer_stop@plt>
movapd %xmm0,%xmm2
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xcf7(%rip),%xmm0
mov    %r14,%rdi
movapd %xmm2,%xmm1
mov    %r15d,%esi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r15d,%edi
movsd  0x8(%rsp),%xmm0
movsd  0xcdd(%rip),%xmm1
movsd  0xcdd(%rip),%xmm2
call   1040 <adjust_rep_count@plt>
movsd  0x8(%rsp),%xmm1
mov    %eax,%r15d
ucomisd 0xcc7(%rip),%xmm1
ja     12c0 <main+0x150>
movsd  0xcb1(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     12c0 <main+0x150>
xor    %eax,%eax
add    $0x668,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%.18f\09%.18f\09%d\0A\00"
@.str.1 = [16 x i8] c"integral_recur\0A\00"
@.str.2 = [37 x i8] c" %10.2f usec %10.6f sec %10d\0A\00"
@.str.3 = [14 x i8] c"integral_gen\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [101 x double]
%5 = alloca [101 x double]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 100, i32* %3
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = getelementptr inbounds [101 x double], [101 x double]* %4, i64 0, i64 0
%18 = call i32 @integral_recur(i32 %15, i32 %16, double* %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = getelementptr inbounds [101 x double], [101 x double]* %5, i64 0, i64 0
%22 = call i32 @integral_gen(i32 %19, i32 %20, double* %21)
store i32 0, i32* %6
%23 = load i32, i32* %2
store i32 %23, i32* %7
br label %24
24: ; preds = %41, %0
%25 = load i32, i32* %6
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = sub nsw i32 %26, %27
%29 = icmp sle i32 %25, %28
br i1 %29, label %30, label %46
30: ; preds = %24
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [101 x double], [101 x double]* %4, i64 0, i64 %32
%34 = load double, double* %33
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [101 x double], [101 x double]* %5, i64 0, i64 %36
%38 = load double, double* %37
%39 = load i32, i32* %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %34, double %38, i32 %39)
br label %41
41: ; preds = %30
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %24
46: ; preds = %24
store i32 10, i32* %8
store double 1.000000e+00, double* %11
store double 2.000000e+00, double* %12
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %86, %46
%49 = call i32 (...) @timer_start()
store i32 0, i32* %13
br label %50
50: ; preds = %59, %48
%51 = load i32, i32* %13
%52 = load i32, i32* %8
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %62
54: ; preds = %50
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = getelementptr inbounds [101 x double], [101 x double]* %4, i64 0, i64 0
%58 = call i32 @integral_recur(i32 %55, i32 %56, double* %57)
br label %59
59: ; preds = %54
%60 = load i32, i32* %13
%61 = add nsw i32 %60, 1
store i32 %61, i32* %13
br label %50
62: ; preds = %50
%63 = call double (...) @timer_stop()
store double %63, double* %9
%64 = load double, double* %9
%65 = load i32, i32* %8
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
store double %67, double* %10
%68 = load double, double* %10
%69 = fmul double %68, 1.000000e+06
%70 = load double, double* %9
%71 = load i32, i32* %8
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %69, double %70, i32 %71)
%73 = load i32, i32* %8
%74 = load double, double* %9
%75 = load double, double* %11
%76 = load double, double* %12
%77 = call i32 @adjust_rep_count(i32 %73, double %74, double %75, double %76)
store i32 %77, i32* %8
br label %78
78: ; preds = %62
%79 = load double, double* %9
%80 = load double, double* %12
%81 = fcmp ogt double %79, %80
br i1 %81, label %86, label %82
82: ; preds = %78
%83 = load double, double* %9
%84 = load double, double* %11
%85 = fcmp olt double %83, %84
br label %86
86: ; preds = %82, %78
%87 = phi i1 [ true, %78 ], [ %85, %82 ]
br i1 %87, label %48, label %88
88: ; preds = %86
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 10, i32* %8
br label %90
90: ; preds = %128, %88
%91 = call i32 (...) @timer_start()
store i32 0, i32* %14
br label %92
92: ; preds = %101, %90
%93 = load i32, i32* %14
%94 = load i32, i32* %8
%95 = icmp sle i32 %93, %94
br i1 %95, label %96, label %104
96: ; preds = %92
%97 = load i32, i32* %2
%98 = load i32, i32* %3
%99 = getelementptr inbounds [101 x double], [101 x double]* %5, i64 0, i64 0
%100 = call i32 @integral_gen(i32 %97, i32 %98, double* %99)
br label %101
101: ; preds = %96
%102 = load i32, i32* %14
%103 = add nsw i32 %102, 1
store i32 %103, i32* %14
br label %92
104: ; preds = %92
%105 = call double (...) @timer_stop()
store double %105, double* %9
%106 = load double, double* %9
%107 = load i32, i32* %8
%108 = sitofp i32 %107 to double
%109 = fdiv double %106, %108
store double %109, double* %10
%110 = load double, double* %10
%111 = fmul double %110, 1.000000e+06
%112 = load double, double* %9
%113 = load i32, i32* %8
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %111, double %112, i32 %113)
%115 = load i32, i32* %8
%116 = load double, double* %9
%117 = load double, double* %11
%118 = load double, double* %12
%119 = call i32 @adjust_rep_count(i32 %115, double %116, double %117, double %118)
store i32 %119, i32* %8
br label %120
120: ; preds = %104
%121 = load double, double* %9
%122 = load double, double* %12
%123 = fcmp ogt double %121, %122
br i1 %123, label %128, label %124
124: ; preds = %120
%125 = load double, double* %9
%126 = load double, double* %11
%127 = fcmp olt double %125, %126
br label %128
128: ; preds = %124, %120
%129 = phi i1 [ true, %120 ], [ %127, %124 ]
br i1 %129, label %90, label %130
130: ; preds = %128
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"%.18f\09%.18f\09%d\0A\00"
@.str.2 = [37 x i8] c" %10.2f usec %10.6f sec %10d\0A\00"
@str = [15 x i8] c"integral_recur\00"
@str.4 = [13 x i8] c"integral_gen\00"
define i32 @main() {
%1 = alloca [101 x double]
%2 = alloca [101 x double]
%3 = bitcast [101 x double]* %1 to i8*
%4 = bitcast [101 x double]* %2 to i8*
%5 = getelementptr inbounds [101 x double], [101 x double]* %1, i64 0, i64 0
%6 = call i32 @integral_recur(i32 0, i32 100, double* %5)
%7 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 0
%8 = call i32 @integral_gen(i32 0, i32 100, double* %7)
br label %11
9: ; preds = %11
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %21
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %19, %11 ]
%13 = trunc i64 %12 to i32
%14 = getelementptr inbounds [101 x double], [101 x double]* %1, i64 0, i64 %12
%15 = load double, double* %14
%16 = getelementptr inbounds [101 x double], [101 x double]* %2, i64 0, i64 %12
%17 = load double, double* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %15, double %17, i32 %13)
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, 101
br i1 %20, label %9, label %11
21: ; preds = %25, %9
%22 = phi i32 [ 10, %9 ], [ %31, %25 ]
%23 = call i32 (...) @timer_start()
%24 = icmp slt i32 %22, 0
br i1 %24, label %25, label %35
25: ; preds = %35, %21
%26 = call double (...) @timer_stop()
%27 = sitofp i32 %22 to double
%28 = fdiv double %26, %27
%29 = fmul double %28, 1.000000e+06
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %29, double %26, i32 %22)
%31 = call i32 @adjust_rep_count(i32 %22, double %26, double 1.000000e+00, double 2.000000e+00)
%32 = fcmp ogt double %26, 2.000000e+00
%33 = fcmp olt double %26, 1.000000e+00
%34 = or i1 %32, %33
br i1 %34, label %21, label %40
35: ; preds = %21, %35
%36 = phi i32 [ %38, %35 ], [ 0, %21 ]
%37 = call i32 @integral_recur(i32 0, i32 100, double* %5)
%38 = add nuw i32 %36, 1
%39 = icmp eq i32 %36, %22
br i1 %39, label %25, label %35
40: ; preds = %25
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
br label %42
42: ; preds = %46, %40
%43 = phi i32 [ 10, %40 ], [ %52, %46 ]
%44 = call i32 (...) @timer_start()
%45 = icmp slt i32 %43, 0
br i1 %45, label %46, label %56
46: ; preds = %56, %42
%47 = call double (...) @timer_stop()
%48 = sitofp i32 %43 to double
%49 = fdiv double %47, %48
%50 = fmul double %49, 1.000000e+06
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %50, double %47, i32 %43)
%52 = call i32 @adjust_rep_count(i32 %43, double %47, double 1.000000e+00, double 2.000000e+00)
%53 = fcmp ogt double %47, 2.000000e+00
%54 = fcmp olt double %47, 1.000000e+00
%55 = or i1 %53, %54
br i1 %55, label %42, label %61
56: ; preds = %42, %56
%57 = phi i32 [ %59, %56 ], [ 0, %42 ]
%58 = call i32 @integral_gen(i32 0, i32 100, double* %7)
%59 = add nuw i32 %57, 1
%60 = icmp eq i32 %57, %43
br i1 %60, label %46, label %56
61: ; preds = %46
ret i32 0
}