#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++) {
    prod = prod * i;
    sum = sum + 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     1186 <sumProd+0x76>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%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    116d <sumProd+0x5d>
mov    %edi,%r14d
neg    %r14d
xorps  %xmm0,%xmm0
movss  0xed7(%rip),%xmm1
mov    $0x1,%ebx
xchg   %ax,%ax
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
mulss  %xmm2,%xmm1
movss  %xmm1,(%rsp)
addss  %xmm2,%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <foo@plt>
movss  (%rsp),%xmm1
movss  0x4(%rsp),%xmm0
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1130 <sumProd+0x20>
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 = %22, %1
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %25
10: ; preds = %6
%11 = load float, float* %4
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to float
%14 = fmul float %11, %13
store float %14, float* %4
%15 = load float, float* %3
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = fadd float %15, %17
store float %18, float* %3
%19 = load float, float* %3
%20 = load float, float* %4
%21 = call i32 @foo(float %19, float %20)
br label %22
22: ; preds = %10
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %6
25: ; 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 [ %12, %4 ], [ 1, %1 ]
%6 = phi float [ %9, %4 ], [ 1.000000e+00, %1 ]
%7 = phi float [ %10, %4 ], [ 0.000000e+00, %1 ]
%8 = sitofp i32 %5 to float
%9 = fmul float %6, %8
%10 = fadd float %7, %8
%11 = tail call i32 @foo(float %10, float %9)
%12 = add nuw i32 %5, 1
%13 = icmp eq i32 %5, %0
br i1 %13, label %3, label %4
}