#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 fmod(double, int);
void IncrementCurtimes(double timeval[], int harmonics, double increment,
                       double detune) {
  int i;
  for (i = 0; i < harmonics; i++) {
    timeval[i] += increment * (2 ^ i) + detune;
    timeval[i] = fmod(timeval[i], 44100);
  }
}


x86 assembly (clang, -O0):
<IncrementCurtimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <IncrementCurtimes+0x8c>
movsd  -0x18(%rbp),%xmm0
mov    -0x24(%rbp),%eax
xor    $0x2,%eax
cvtsi2sd %eax,%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0xac44,%edi
call   1030 <fmod@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1130 <IncrementCurtimes+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IncrementCurtimes>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1184 <IncrementCurtimes+0x74>
movapd %xmm0,%xmm2
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
xor    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
mov    $0xac44,%edi
call   1030 <fmod@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <IncrementCurtimes+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @IncrementCurtimes(double* %0, i32 %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %37, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = load double, double* %7
%16 = load i32, i32* %9
%17 = xor i32 2, %16
%18 = sitofp i32 %17 to double
%19 = load double, double* %8
%20 = call double @llvm.fmuladd.f64(double %15, double %18, double %19)
%21 = load double*, double** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fadd double %25, %20
store double %26, double* %24
%27 = load double*, double** %5
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = call double @fmod(double %31, i32 44100)
%33 = load double*, double** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
br label %37
37: ; preds = %14
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %10
40: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @IncrementCurtimes(double* nocapture %0, i32 %1, double %2, double %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %20
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %18, %8 ]
%10 = trunc i64 %9 to i32
%11 = xor i32 %10, 2
%12 = sitofp i32 %11 to double
%13 = tail call double @llvm.fmuladd.f64(double %2, double %12, double %3)
%14 = getelementptr inbounds double, double* %0, i64 %9
%15 = load double, double* %14
%16 = fadd double %13, %15
store double %16, double* %14
%17 = tail call double @fmod(double %16, i32 44100)
store double %17, double* %14
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %8, %4
ret void
}