#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++) {
    sum = sum + i;
    prod = prod * i;
    if (n % 2 == 0) {
      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     119f <sumProd+0x8f>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118c <sumProd+0x7c>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <foo@plt>
jmp    1191 <sumProd+0x81>
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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1186 <sumProd+0x76>
mov    %edi,%r14d
mov    %edi,%ebx
neg    %ebx
xorps  %xmm0,%xmm0
movss  0xed2(%rip),%xmm1
mov    $0x1,%ebp
jmp    1152 <sumProd+0x42>
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1186 <sumProd+0x76>
xorps  %xmm2,%xmm2
cvtsi2ss %ebp,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm2,%xmm1
test   $0x1,%r14b
jne    1140 <sumProd+0x30>
movss  %xmm0,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
call   1030 <foo@plt>
movss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
jmp    1140 <sumProd+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 float, float* %3
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to float
%14 = fadd float %11, %13
store float %14, float* %3
%15 = load float, float* %4
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = fmul float %15, %17
store float %18, float* %4
%19 = load i32, i32* %2
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %10
%23 = load float, float* %3
%24 = load float, float* %4
%25 = call i32 @foo(float %23, float %24)
br label %26
26: ; preds = %22, %10
br label %27
27: ; preds = %26
%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 %6, label %3
3: ; preds = %1
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
br label %7
6: ; preds = %16, %1
ret void
7: ; preds = %3, %16
%8 = phi i32 [ 1, %3 ], [ %17, %16 ]
%9 = phi float [ 1.000000e+00, %3 ], [ %13, %16 ]
%10 = phi float [ 0.000000e+00, %3 ], [ %12, %16 ]
%11 = sitofp i32 %8 to float
%12 = fadd float %10, %11
%13 = fmul float %9, %11
br i1 %5, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @foo(float %12, float %13)
br label %16
16: ; preds = %7, %14
%17 = add nuw i32 %8, 1
%18 = icmp eq i32 %8, %0
br i1 %18, label %6, label %7
}