#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 /*<<< orphan*/ foo(float, float);
void sumProd(int n) {
  float sum = 0.0;
  float prod = 1.0;
  for (int i = 1; i <= n; i++) {
    if (i % 2)
      sum += i;
    prod = prod * i;
    foo(sum, prod);
  }
}


x86 assembly (clang, -O0):
<sumProd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xed5(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1196 <sumProd+0x86>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1166 <sumProd+0x56>
cvtsi2ssl -0x10(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <foo@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <sumProd+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumProd>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    118f <sumProd+0x7f>
mov    %edi,%r14d
neg    %r14d
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xed1(%rip),%xmm0
movss  %xmm0,(%rsp)
mov    $0x1,%ebx
jmp    1176 <sumProd+0x66>
nopl   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  (%rsp),%xmm1
mulss  %xmm2,%xmm1
movss  %xmm0,0x4(%rsp)
movss  %xmm1,(%rsp)
call   1030 <foo@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     118f <sumProd+0x7f>
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
movss  0xe7f(%rip),%xmm1
test   $0x1,%bl
je     1140 <sumProd+0x30>
movaps %xmm2,%xmm1
jmp    1140 <sumProd+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sumProd(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 %0, i32* %2
store float 0.000000e+00, float* %3
store float 1.000000e+00, float* %4
store i32 1, i32* %5
br label %6
6: ; preds = %27, %1
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %30
10: ; preds = %6
%11 = load i32, i32* %5
%12 = srem i32 %11, 2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to float
%17 = load float, float* %3
%18 = fadd float %17, %16
store float %18, float* %3
br label %19
19: ; preds = %14, %10
%20 = load float, float* %4
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to float
%23 = fmul float %20, %22
store float %23, float* %4
%24 = load float, float* %3
%25 = load float, float* %4
%26 = call i32 @foo(float %24, float %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %6
30: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @sumProd(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %4
3: ; preds = %4, %1
ret void
4: ; preds = %1, %4
%5 = phi i32 [ %15, %4 ], [ 1, %1 ]
%6 = phi float [ %13, %4 ], [ 1.000000e+00, %1 ]
%7 = phi float [ %12, %4 ], [ 0.000000e+00, %1 ]
%8 = and i32 %5, 1
%9 = icmp eq i32 %8, 0
%10 = sitofp i32 %5 to float
%11 = select i1 %9, float -0.000000e+00, float %10
%12 = fadd float %7, %11
%13 = fmul float %6, %10
%14 = tail call i32 @foo(float %12, float %13)
%15 = add nuw i32 %5, 1
%16 = icmp eq i32 %5, %0
br i1 %16, label %3, label %4
}