#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;
    foo(sum, prod);
    prod = prod * i;
  }
}


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  -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>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
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
sub    $0x18,%rsp
test   %edi,%edi
jle    1193 <sumProd+0x83>
mov    %edi,%r14d
neg    %r14d
xorps  %xmm0,%xmm0
movss  0xed4(%rip),%xmm1
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm1,0xc(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  %xmm1,0x14(%rsp)
addss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <foo@plt>
movss  0xc(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
mulss  0x14(%rsp),%xmm1
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1140 <sumProd+0x30>
add    $0x18,%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* %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* %3
%16 = load float, float* %4
%17 = call i32 @foo(float %15, float %16)
%18 = load float, float* %4
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to float
%21 = fmul float %18, %20
store float %21, float* %4
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 [ %11, %4 ], [ 1.000000e+00, %1 ]
%7 = phi float [ %9, %4 ], [ 0.000000e+00, %1 ]
%8 = sitofp i32 %5 to float
%9 = fadd float %7, %8
%10 = tail call i32 @foo(float %9, float %6)
%11 = fmul float %6, %8
%12 = add nuw i32 %5, 1
%13 = icmp eq i32 %5, %0
br i1 %13, label %3, label %4
}