#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*/ printf(char *, float, double);
int main(void) {
  float sf = 0.0f, xf = 0.1f;
  double sd = 0.0, xd = 0.1f;
  int i = 1;
  for (; i <= 10000; i++) {
    sf = sf + xf + i;
    sd = sd + xd + i;
  }
  printf("sf = %f\n sd = %f\n", sf, sd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xed9(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x2710,-0x24(%rbp)
jg     119b <main+0x8b>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <main+0x40>
movss  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm1,%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
movsd  0xedb(%rip),%xmm2
movss  0xeeb(%rip),%xmm3
movsd  0xed3(%rip),%xmm4
movsd  0xed3(%rip),%xmm5
nopl   (%rax)
addss  %xmm3,%xmm0
xorps  %xmm6,%xmm6
cvtsi2ss %eax,%xmm6
addss  %xmm0,%xmm6
addsd  %xmm4,%xmm1
addsd  %xmm2,%xmm1
addss  %xmm3,%xmm6
lea    0x1(%rax),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
addss  %xmm6,%xmm0
movapd %xmm1,%xmm6
addsd  %xmm4,%xmm6
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
addsd  %xmm6,%xmm1
addsd  %xmm5,%xmm2
add    $0x2,%eax
cmp    $0x2711,%eax
jne    1140 <main+0x30>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"sf = %f\0A sd = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0x3FB99999A0000000, float* %3
store double 0.000000e+00, double* %4
store double 0x3FB99999A0000000, double* %5
store i32 1, i32* %6
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %6
%9 = icmp sle i32 %8, 10000
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load float, float* %2
%12 = load float, float* %3
%13 = fadd float %11, %12
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to float
%16 = fadd float %13, %15
store float %16, float* %2
%17 = load double, double* %4
%18 = load double, double* %5
%19 = fadd double %17, %18
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = fadd double %19, %21
store double %22, double* %4
br label %23
23: ; preds = %10
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %7
26: ; preds = %7
%27 = load float, float* %2
%28 = load double, double* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), float %27, double %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"sf = %f\0A sd = %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 1, %0 ], [ %18, %1 ]
%3 = phi float [ 0.000000e+00, %0 ], [ %14, %1 ]
%4 = phi double [ 0.000000e+00, %0 ], [ %17, %1 ]
%5 = fadd float %3, 0x3FB99999A0000000
%6 = sitofp i32 %2 to float
%7 = fadd float %5, %6
%8 = fadd double %4, 0x3FB99999A0000000
%9 = sitofp i32 %2 to double
%10 = fadd double %8, %9
%11 = add nuw nsw i32 %2, 1
%12 = fadd float %7, 0x3FB99999A0000000
%13 = sitofp i32 %11 to float
%14 = fadd float %12, %13
%15 = fadd double %10, 0x3FB99999A0000000
%16 = sitofp i32 %11 to double
%17 = fadd double %15, %16
%18 = add nuw nsw i32 %2, 2
%19 = icmp eq i32 %18, 10001
br i1 %19, label %20, label %1
20: ; preds = %1
%21 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), float %14, double %17)
ret i32 0
}