#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, int);
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;
    foo(sum, prod, n);
  }
}


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     1189 <sumProd+0x79>
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)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mov    -0x4(%rbp),%edi
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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1181 <sumProd+0x71>
mov    %edi,%r14d
mov    %edi,%ebx
neg    %ebx
xorps  %xmm0,%xmm0
movss  0xed2(%rip),%xmm1
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm2,%xmm2
cvtsi2ss %ebp,%xmm2
addss  %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
mulss  %xmm2,%xmm1
movss  %xmm1,0x8(%rsp)
mov    %r14d,%edi
call   1030 <foo@plt>
movss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    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 = %23, %1
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %26
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 float, float* %3
%20 = load float, float* %4
%21 = load i32, i32* %2
%22 = call i32 @foo(float %19, float %20, i32 %21)
br label %23
23: ; preds = %10
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; 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 [ %10, %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 = fmul float %6, %8
%11 = tail call i32 @foo(float %9, float %10, i32 %0)
%12 = add nuw i32 %5, 1
%13 = icmp eq i32 %5, %0
br i1 %13, label %3, label %4
}