#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 */
scalar_t__ cntevents(double, double, double);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ flteq(double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
double pow(double, double);
int /*<<< orphan*/ stdout;
void get_dur(double *bbrk, int bbrksize, double in_dur, int mode) {
  int n, m;
  double lasttime, lastval, thistime, thisval, newtime = 0;
  int done;
  double tratio;
  thistime = 0;
  lasttime = bbrk[0];
  lastval = bbrk[1];
  if (mode == 1) {
    for (n = 1; n < bbrksize * 2; n += 2)
      bbrk[n] = pow(2.0, bbrk[n] / 12.0);
  }
  done = 0;
  for (m = 2, n = 1; n < bbrksize; m += 2, n++) {
    thistime = bbrk[m];
    thisval = bbrk[m + 1];
    if ((in_dur > 0.0) && (thistime > in_dur)) {
      done = 1;
      tratio = (in_dur - lasttime) / (thistime - lasttime);
      if (!flteq(tratio, 0.0)) {
        thistime = in_dur;
        thisval = ((thisval - lastval) * tratio) + lastval;
        newtime += cntevents(thistime - lasttime, lastval, thisval);
      }
    } else {
      newtime += cntevents(thistime - lasttime, lastval, thisval);
    }
    if (done)
      break;
    lasttime = thistime;
    lastval = thisval;
  }
  if (!done && (thistime < in_dur)) {
    thistime = in_dur;
    thisval = lastval;
    newtime += cntevents(thistime - lasttime, lastval, thisval);
  }
  fprintf(stdout, "INFO: DURATION is %lf\n", newtime);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<get_dur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11fa <get_dur+0xaa>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11f5 <get_dur+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xe3f(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
call   1070 <pow@plt>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <get_dur+0x53>
jmp    11fa <get_dur+0xaa>
movl   $0x0,-0x54(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    135a <get_dur+0x20a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12f8 <get_dur+0x1a8>
movsd  -0x40(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12f8 <get_dur+0x1a8>
movl   $0x1,-0x54(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1050 <flteq@plt>
cmp    $0x0,%eax
jne    12f3 <get_dur+0x1a3>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
call   1030 <cntevents@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1320 <get_dur+0x1d0>
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
call   1030 <cntevents@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     132f <get_dur+0x1df>
jmp    135a <get_dur+0x20a>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    120f <get_dur+0xbf>
cmpl   $0x0,-0x54(%rbp)
jne    13b4 <get_dur+0x264>
movsd  -0x40(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13b4 <get_dur+0x264>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
call   1030 <cntevents@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
movsd  -0x50(%rbp),%xmm0
lea    0xc47(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dur>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %esi,%r14d
mov    %rdi,%r12
movsd  (%rdi),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,(%rsp)
cmp    $0x1,%edx
jne    11e2 <get_dur+0x92>
test   %r14d,%r14d
jle    12bc <get_dur+0x16c>
movsd  (%rsp),%xmm0
divsd  0xe6a(%rip),%xmm0
call   1040 <exp2@plt>
movsd  %xmm0,0x8(%r12)
cmp    $0x1,%r14d
je     11e2 <get_dur+0x92>
lea    (%r14,%r14,1),%eax
movslq %eax,%r15
mov    $0x3,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12,%rbx,8),%xmm0
divsd  0xe32(%rip),%xmm0
call   1040 <exp2@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x2,%rbx
cmp    %r15,%rbx
jl     11c0 <get_dur+0x70>
xorpd  %xmm0,%xmm0
cmp    $0x2,%r14d
jl     12c0 <get_dur+0x170>
add    $0x18,%r12
add    $0xffffffff,%r14d
xorpd  %xmm4,%xmm4
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm5
jmp    125b <get_dur+0x10b>
nopl   0x0(%rax)
movapd %xmm3,%xmm0
subsd  %xmm5,%xmm0
movsd  (%rsp),%xmm2
movsd  %xmm3,0x8(%rsp)
call   1030 <cntevents@plt>
movsd  0x8(%rsp),%xmm3
movsd  (%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x10(%rsp),%xmm4
addsd  %xmm0,%xmm4
add    $0x10,%r12
movapd %xmm2,%xmm1
movapd %xmm3,%xmm5
movapd %xmm3,%xmm0
add    $0xffffffff,%r14d
je     12cf <get_dur+0x17f>
movsd  %xmm4,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
ucomisd 0xd99(%rip),%xmm0
movsd  -0x8(%r12),%xmm3
movsd  (%r12),%xmm2
movsd  %xmm2,(%rsp)
jbe    1210 <get_dur+0xc0>
ucomisd %xmm0,%xmm3
jbe    1210 <get_dur+0xc0>
movsd  %xmm1,0x8(%rsp)
subsd  %xmm5,%xmm0
movsd  %xmm0,0x18(%rsp)
subsd  %xmm5,%xmm3
divsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x20(%rsp)
call   1060 <flteq@plt>
test   %eax,%eax
je     132f <get_dur+0x1df>
movsd  0x10(%rsp),%xmm4
jmp    1304 <get_dur+0x1b4>
xorpd  %xmm0,%xmm0
xorpd  %xmm4,%xmm4
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1304 <get_dur+0x1b4>
movapd %xmm1,%xmm0
subsd  %xmm3,%xmm0
movapd %xmm2,%xmm1
movsd  %xmm4,0x10(%rsp)
call   1030 <cntevents@plt>
movsd  0x10(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm4
mov    0x2cd5(%rip),%rbx
mov    (%rbx),%edi
lea    0xcfc(%rip),%rsi
movapd %xmm4,%xmm0
call   1050 <fprintf@plt>
mov    (%rbx),%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <fflush@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm2
mulsd  0x20(%rsp),%xmm2
addsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm0
call   1030 <cntevents@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x10(%rsp),%xmm4
jmp    1300 <get_dur+0x1b0>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [23 x i8] c"INFO: DURATION is %lf\0A\00"
define void @get_dur(double* %0, i32 %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %13
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
store double %20, double* %11
%21 = load double*, double** %5
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
store double %23, double* %12
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %48
26: ; preds = %4
store i32 1, i32* %9
br label %27
27: ; preds = %44, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = mul nsw i32 %29, 2
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %47
32: ; preds = %27
%33 = load double*, double** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = fdiv double %37, 1.200000e+01
%39 = call double @pow(double 2.000000e+00, double %38)
%40 = load double*, double** %5
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
br label %44
44: ; preds = %32
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 2
store i32 %46, i32* %9
br label %27
47: ; preds = %27
br label %48
48: ; preds = %47, %4
store i32 0, i32* %16
store i32 2, i32* %10
store i32 1, i32* %9
br label %49
49: ; preds = %117, %48
%50 = load i32, i32* %9
%51 = load i32, i32* %6
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %122
53: ; preds = %49
%54 = load double*, double** %5
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
store double %58, double* %13
%59 = load double*, double** %5
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %59, i64 %62
%64 = load double, double* %63
store double %64, double* %14
%65 = load double, double* %7
%66 = fcmp ogt double %65, 0.000000e+00
br i1 %66, label %67, label %100
67: ; preds = %53
%68 = load double, double* %13
%69 = load double, double* %7
%70 = fcmp ogt double %68, %69
br i1 %70, label %71, label %100
71: ; preds = %67
store i32 1, i32* %16
%72 = load double, double* %7
%73 = load double, double* %11
%74 = fsub double %72, %73
%75 = load double, double* %13
%76 = load double, double* %11
%77 = fsub double %75, %76
%78 = fdiv double %74, %77
store double %78, double* %17
%79 = load double, double* %17
%80 = call i32 @flteq(double %79, double 0.000000e+00)
%81 = icmp ne i32 %80, 0
br i1 %81, label %99, label %82
82: ; preds = %71
%83 = load double, double* %7
store double %83, double* %13
%84 = load double, double* %14
%85 = load double, double* %12
%86 = fsub double %84, %85
%87 = load double, double* %17
%88 = load double, double* %12
%89 = call double @llvm.fmuladd.f64(double %86, double %87, double %88)
store double %89, double* %14
%90 = load double, double* %13
%91 = load double, double* %11
%92 = fsub double %90, %91
%93 = load double, double* %12
%94 = load double, double* %14
%95 = call i64 @cntevents(double %92, double %93, double %94)
%96 = sitofp i64 %95 to double
%97 = load double, double* %15
%98 = fadd double %97, %96
store double %98, double* %15
br label %99
99: ; preds = %82, %71
br label %110
100: ; preds = %67, %53
%101 = load double, double* %13
%102 = load double, double* %11
%103 = fsub double %101, %102
%104 = load double, double* %12
%105 = load double, double* %14
%106 = call i64 @cntevents(double %103, double %104, double %105)
%107 = sitofp i64 %106 to double
%108 = load double, double* %15
%109 = fadd double %108, %107
store double %109, double* %15
br label %110
110: ; preds = %100, %99
%111 = load i32, i32* %16
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %114
113: ; preds = %110
br label %122
114: ; preds = %110
%115 = load double, double* %13
store double %115, double* %11
%116 = load double, double* %14
store double %116, double* %12
br label %117
117: ; preds = %114
%118 = load i32, i32* %10
%119 = add nsw i32 %118, 2
store i32 %119, i32* %10
%120 = load i32, i32* %9
%121 = add nsw i32 %120, 1
store i32 %121, i32* %9
br label %49
122: ; preds = %113, %49
%123 = load i32, i32* %16
%124 = icmp ne i32 %123, 0
br i1 %124, label %141, label %125
125: ; preds = %122
%126 = load double, double* %13
%127 = load double, double* %7
%128 = fcmp olt double %126, %127
br i1 %128, label %129, label %141
129: ; preds = %125
%130 = load double, double* %7
store double %130, double* %13
%131 = load double, double* %12
store double %131, double* %14
%132 = load double, double* %13
%133 = load double, double* %11
%134 = fsub double %132, %133
%135 = load double, double* %12
%136 = load double, double* %14
%137 = call i64 @cntevents(double %134, double %135, double %136)
%138 = sitofp i64 %137 to double
%139 = load double, double* %15
%140 = fadd double %139, %138
store double %140, double* %15
br label %141
141: ; preds = %129, %125, %122
%142 = load i32, i32* @stdout
%143 = load double, double* %15
%144 = call i32 @fprintf(i32 %142, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %143)
%145 = load i32, i32* @stdout
%146 = call i32 @fflush(i32 %145)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [23 x i8] c"INFO: DURATION is %lf\0A\00"
define void @get_dur(double* nocapture %0, i32 %1, double %2, i32 %3) {
%5 = load double, double* %0
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = icmp eq i32 %3, 1
br i1 %8, label %9, label %27
9: ; preds = %4
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %64
11: ; preds = %9
%12 = shl nuw nsw i32 %1, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %0, i64 1
%15 = fdiv double %7, 1.200000e+01
%16 = tail call double @exp2(double %15)
store double %16, double* %14
%17 = icmp eq i32 %1, 1
br i1 %17, label %27, label %18
18: ; preds = %11, %18
%19 = phi i64 [ %25, %18 ], [ 3, %11 ]
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %0, i64 %19
%23 = fdiv double %21, 1.200000e+01
%24 = tail call double @exp2(double %23)
store double %24, double* %22
%25 = add nuw nsw i64 %19, 2
%26 = icmp slt i64 %25, %13
br i1 %26, label %18, label %27
27: ; preds = %18, %11, %4
%28 = icmp sgt i32 %1, 1
br i1 %28, label %29, label %64
29: ; preds = %27
%30 = fcmp ogt double %2, 0.000000e+00
br label %31
31: ; preds = %29, %56
%32 = phi i64 [ 2, %29 ], [ %61, %56 ]
%33 = phi i32 [ 1, %29 ], [ %62, %56 ]
%34 = phi double [ 0.000000e+00, %29 ], [ %60, %56 ]
%35 = phi double [ %7, %29 ], [ %41, %56 ]
%36 = phi double [ %5, %29 ], [ %38, %56 ]
%37 = getelementptr inbounds double, double* %0, i64 %32
%38 = load double, double* %37
%39 = or i64 %32, 1
%40 = getelementptr inbounds double, double* %0, i64 %39
%41 = load double, double* %40
%42 = fcmp ogt double %38, %2
%43 = select i1 %30, i1 %42, i1 false
br i1 %43, label %44, label %56
44: ; preds = %31
%45 = fsub double %2, %36
%46 = fsub double %38, %36
%47 = fdiv double %45, %46
%48 = tail call i32 @flteq(double %47, double 0.000000e+00)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %75
50: ; preds = %44
%51 = fsub double %41, %35
%52 = tail call double @llvm.fmuladd.f64(double %51, double %47, double %35)
%53 = tail call i64 @cntevents(double %45, double %35, double %52)
%54 = sitofp i64 %53 to double
%55 = fadd double %34, %54
br label %75
56: ; preds = %31
%57 = fsub double %38, %36
%58 = tail call i64 @cntevents(double %57, double %35, double %41)
%59 = sitofp i64 %58 to double
%60 = fadd double %34, %59
%61 = add nuw nsw i64 %32, 2
%62 = add nuw nsw i32 %33, 1
%63 = icmp eq i32 %62, %1
br i1 %63, label %64, label %31
64: ; preds = %56, %9, %27
%65 = phi double [ %5, %27 ], [ %5, %9 ], [ %38, %56 ]
%66 = phi double [ %7, %27 ], [ %7, %9 ], [ %41, %56 ]
%67 = phi double [ 0.000000e+00, %27 ], [ 0.000000e+00, %9 ], [ %38, %56 ]
%68 = phi double [ 0.000000e+00, %27 ], [ 0.000000e+00, %9 ], [ %60, %56 ]
%69 = fcmp olt double %67, %2
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = fsub double %2, %65
%72 = tail call i64 @cntevents(double %71, double %66, double %66)
%73 = sitofp i64 %72 to double
%74 = fadd double %68, %73
br label %75
75: ; preds = %44, %50, %70, %64
%76 = phi double [ %68, %64 ], [ %74, %70 ], [ %55, %50 ], [ %34, %44 ]
%77 = load i32, i32* @stdout
%78 = tail call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %76)
%79 = load i32, i32* @stdout
%80 = tail call i32 @fflush(i32 %79)
ret void
}