#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 calcDoubleMul(void) {
  long stTim, endTim;
  int i, j;
  double a;
  stTim = clock();
  a = 0.0;
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      a *= (double)j;
    }
  }
  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):
<calcDoubleMul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1183 <calcDoubleMul+0x73>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    1170 <calcDoubleMul+0x60>
cvtsi2sdl -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <calcDoubleMul+0x36>
jmp    1175 <calcDoubleMul+0x65>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <calcDoubleMul+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    0x2e44(%rip),%rax
cmpl   $0x0,(%rax)
jle    11db <calcDoubleMul+0xcb>
mov    $0x3e8,%eax
mov    0x2e2f(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11d6 <calcDoubleMul+0xc6>
movslq -0x24(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11db <calcDoubleMul+0xcb>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcDoubleMul>:
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 <calcDoubleMul+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 @calcDoubleMul() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = call i64 (...) @clock()
store i64 %7, i64* %1
store double 0.000000e+00, double* %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 double
%18 = load double, double* %5
%19 = fmul double %18, %17
store double %19, double* %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
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 @calcDoubleMul() {
%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
}