#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 */
double f(double);
int g(double);
double intCompSimp(double *X, double h, int c) {
  double integral = f(X[0]);
  int i;
  while (c == 1) {
    for (i = 1; i < 100; i++) {
      if ((i % 2) == 0)
        integral += 2 * f(X[i]);
      else
        (integral += 4 * f(X[i]));
    }
    integral += f(X[100]);
    return (integral * (h / 3));
  }
  while (c == 2) {
    for (i = 1; i < 100; i++) {
      if ((i % 2) == 0)
        integral += 2 * g(X[i]);
      else
        (integral += 4 * g(X[i]));
    }
    integral += f(X[100]);
    return (integral * (h / 3));
  }
}


x86 assembly (clang, -O0):
<intCompSimp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    121c <intCompSimp+0xfc>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jge    11dd <intCompSimp+0xbd>
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119e <intCompSimp+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <f@plt>
movsd  -0x28(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11ca <intCompSimp+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <f@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11cf <intCompSimp+0xaf>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1157 <intCompSimp+0x37>
mov    -0x10(%rbp),%rax
movsd  0x320(%rax),%xmm0
call   1030 <f@plt>
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xdf6(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12e8 <intCompSimp+0x1c8>
jmp    1221 <intCompSimp+0x101>
cmpl   $0x2,-0x1c(%rbp)
jne    12e8 <intCompSimp+0x1c8>
movl   $0x1,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jge    12ae <intCompSimp+0x18e>
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1278 <intCompSimp+0x158>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <g@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    129b <intCompSimp+0x17b>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <g@plt>
shl    $0x2,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12a0 <intCompSimp+0x180>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1232 <intCompSimp+0x112>
mov    -0x10(%rbp),%rax
movsd  0x320(%rax),%xmm0
call   1030 <f@plt>
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd25(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intCompSimp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%r15
movsd  (%rdi),%xmm0
call   1030 <f@plt>
cmp    $0x1,%ebp
je     1198 <intCompSimp+0x78>
cmp    $0x2,%ebp
movsd  0x10(%rsp),%xmm1
jne    120a <intCompSimp+0xea>
mov    $0x1,%ebp
movsd  %xmm0,0x8(%rsp)
nopl   (%rax)
movsd  (%r15,%rbp,8),%xmm0
call   1040 <g@plt>
mov    %ebp,%ecx
and    $0x1,%cl
add    $0x1,%cl
shl    %cl,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%rbp
cmp    $0x64,%rbp
jne    1160 <intCompSimp+0x40>
jmp    11e4 <intCompSimp+0xc4>
mov    $0x1,%ebp
lea    0xe5c(%rip),%r14
movsd  %xmm0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
test   $0x1,%bpl
sete   %bl
movsd  (%r15,%rbp,8),%xmm0
call   1030 <f@plt>
mulsd  (%r14,%rbx,8),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%rbp
cmp    $0x64,%rbp
jne    11b0 <intCompSimp+0x90>
movsd  0x320(%r15),%xmm0
call   1030 <f@plt>
addsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  0xe0a(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @intCompSimp(double* %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store double* %0, double** %5
store double %1, double* %6
store i32 %2, i32* %7
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = call double @f(double %12)
store double %13, double* %8
br label %14
14: ; preds = %3
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %58
17: ; preds = %14
store i32 1, i32* %9
br label %18
18: ; preds = %44, %17
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 100
br i1 %20, label %21, label %47
21: ; preds = %18
%22 = load i32, i32* %9
%23 = srem i32 %22, 2
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load double*, double** %5
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = call double @f(double %30)
%32 = load double, double* %8
%33 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %31, double %32)
store double %33, double* %8
br label %43
34: ; preds = %21
%35 = load double*, double** %5
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = call double @f(double %39)
%41 = load double, double* %8
%42 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %40, double %41)
store double %42, double* %8
br label %43
43: ; preds = %34, %25
br label %44
44: ; preds = %43
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %18
47: ; preds = %18
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 100
%50 = load double, double* %49
%51 = call double @f(double %50)
%52 = load double, double* %8
%53 = fadd double %52, %51
store double %53, double* %8
%54 = load double, double* %8
%55 = load double, double* %6
%56 = fdiv double %55, 3.000000e+00
%57 = fmul double %54, %56
store double %57, double* %4
br label %107
58: ; preds = %14
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %107
62: ; preds = %59
store i32 1, i32* %9
br label %63
63: ; preds = %93, %62
%64 = load i32, i32* %9
%65 = icmp slt i32 %64, 100
br i1 %65, label %66, label %96
66: ; preds = %63
%67 = load i32, i32* %9
%68 = srem i32 %67, 2
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %81
70: ; preds = %66
%71 = load double*, double** %5
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = call i32 @g(double %75)
%77 = mul nsw i32 2, %76
%78 = sitofp i32 %77 to double
%79 = load double, double* %8
%80 = fadd double %79, %78
store double %80, double* %8
br label %92
81: ; preds = %66
%82 = load double*, double** %5
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %82, i64 %84
%86 = load double, double* %85
%87 = call i32 @g(double %86)
%88 = mul nsw i32 4, %87
%89 = sitofp i32 %88 to double
%90 = load double, double* %8
%91 = fadd double %90, %89
store double %91, double* %8
br label %92
92: ; preds = %81, %70
br label %93
93: ; preds = %92
%94 = load i32, i32* %9
%95 = add nsw i32 %94, 1
store i32 %95, i32* %9
br label %63
96: ; preds = %63
%97 = load double*, double** %5
%98 = getelementptr inbounds double, double* %97, i64 100
%99 = load double, double* %98
%100 = call double @f(double %99)
%101 = load double, double* %8
%102 = fadd double %101, %100
store double %102, double* %8
%103 = load double, double* %8
%104 = load double, double* %6
%105 = fdiv double %104, 3.000000e+00
%106 = fmul double %103, %105
store double %106, double* %4
br label %107
107: ; preds = %47, %96, %59
%108 = load double, double* %4
ret double %108
}

LLVM IR (-O2):
define double @intCompSimp(double* nocapture %0, double %1, i32 %2) {
%4 = load double, double* %0
%5 = tail call double @f(double %4)
switch i32 %2, label %41 [
i32 1, label %6
i32 2, label %19
]
6: ; preds = %3, %6
%7 = phi i64 [ %17, %6 ], [ 1, %3 ]
%8 = phi double [ %16, %6 ], [ %5, %3 ]
%9 = and i64 %7, 1
%10 = icmp eq i64 %9, 0
%11 = getelementptr inbounds double, double* %0, i64 %7
%12 = load double, double* %11
%13 = tail call double @f(double %12)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+00, double %8)
%15 = tail call double @llvm.fmuladd.f64(double %13, double 4.000000e+00, double %8)
%16 = select i1 %10, double %14, double %15
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %33, label %6
19: ; preds = %3, %19
%20 = phi i64 [ %31, %19 ], [ 1, %3 ]
%21 = phi double [ %30, %19 ], [ %5, %3 ]
%22 = and i64 %20, 1
%23 = icmp eq i64 %22, 0
%24 = getelementptr inbounds double, double* %0, i64 %20
%25 = load double, double* %24
%26 = tail call i32 @g(double %25)
%27 = select i1 %23, i32 1, i32 2
%28 = shl nsw i32 %26, %27
%29 = sitofp i32 %28 to double
%30 = fadd double %21, %29
%31 = add nuw nsw i64 %20, 1
%32 = icmp eq i64 %31, 100
br i1 %32, label %33, label %19
33: ; preds = %19, %6
%34 = phi double [ %16, %6 ], [ %30, %19 ]
%35 = getelementptr inbounds double, double* %0, i64 100
%36 = load double, double* %35
%37 = tail call double @f(double %36)
%38 = fadd double %34, %37
%39 = fdiv double %1, 3.000000e+00
%40 = fmul double %39, %38
br label %41
41: ; preds = %33, %3
%42 = phi double [ undef, %3 ], [ %40, %33 ]
ret double %42
}