#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 CLOCKS_PER_SEC;
long clock();
long calcFloatAdd(void) {
  long stTim, endTim;
  int i, j;
  float a;
  stTim = clock();
  a = 0.0f;
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      a += j;
    }
    a = 0.0f;
  }
  endTim = clock();
  endTim -= stTim;
  if (CLOCKS_PER_SEC > 0) {
    int time_dd = 1000 / CLOCKS_PER_SEC;
    if (time_dd > 0)
      endTim *= time_dd;
  }
  return endTim;
}


x86 assembly (clang, -O0):
<calcFloatAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1186 <calcFloatAdd+0x76>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    1170 <calcFloatAdd+0x60>
cvtsi2ssl -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <calcFloatAdd+0x36>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <calcFloatAdd+0x22>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    0x2e41(%rip),%rax
cmpl   $0x0,(%rax)
jle    11de <calcFloatAdd+0xce>
mov    $0x3e8,%eax
mov    0x2e2c(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11d9 <calcFloatAdd+0xc9>
movslq -0x20(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11de <calcFloatAdd+0xce>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcFloatAdd>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rcx
sub    %rbx,%rcx
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
test   %esi,%esi
jle    1150 <calcFloatAdd+0x40>
mov    $0x3e8,%eax
xor    %edx,%edx
div    %esi
cmp    $0x3e9,%esi
mov    $0x1,%edx
cmovb  %eax,%edx
imul   %rdx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i32 0
define i64 @calcFloatAdd() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
%7 = call i64 (...) @clock()
store i64 %7, i64* %1
store float 0.000000e+00, float* %5
store i32 0, i32* %3
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10000
br i1 %10, label %11, label %27
11: ; preds = %8
store i32 0, i32* %4
br label %12
12: ; preds = %20, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 10000
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to float
%18 = load float, float* %5
%19 = fadd float %18, %17
store float %19, float* %5
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %12
23: ; preds = %12
store float 0.000000e+00, float* %5
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
%28 = call i64 (...) @clock()
store i64 %28, i64* %2
%29 = load i64, i64* %1
%30 = load i64, i64* %2
%31 = sub nsw i64 %30, %29
store i64 %31, i64* %2
%32 = load i32, i32* @CLOCKS_PER_SEC
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %27
%35 = load i32, i32* @CLOCKS_PER_SEC
%36 = sdiv i32 1000, %35
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = load i64, i64* %2
%43 = mul nsw i64 %42, %41
store i64 %43, i64* %2
br label %44
44: ; preds = %39, %34
br label %45
45: ; preds = %44, %27
%46 = load i64, i64* %2
ret i64 %46
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i32 0
define i64 @calcFloatAdd() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sub nsw i64 %2, %1
%4 = load i32, i32* @CLOCKS_PER_SEC
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = udiv i32 1000, %4
%8 = icmp ugt i32 %4, 1000
%9 = select i1 %8, i32 1, i32 %7
%10 = zext i32 %9 to i64
%11 = mul nsw i64 %3, %10
br label %12
12: ; preds = %6, %0
%13 = phi i64 [ %11, %6 ], [ %3, %0 ]
ret i64 %13
}