#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();
int /*<<< orphan*/ foo();
long calcFuncCall(void) {
  long stTim, endTim;
  int i, j;
  stTim = clock();
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      foo();
    }
  }
  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):
<calcFuncCall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1183 <calcFuncCall+0x63>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    1170 <calcFuncCall+0x50>
mov    $0x0,%al
call   1040 <foo@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <calcFuncCall+0x2e>
jmp    1175 <calcFuncCall+0x55>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <calcFuncCall+0x1a>
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 <calcFuncCall+0xbb>
mov    $0x3e8,%eax
mov    0x2e2f(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11d6 <calcFuncCall+0xb6>
movslq -0x1c(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11db <calcFuncCall+0xbb>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcFuncCall>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
xor    %ebp,%ebp
mov    $0x2710,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <foo@plt>
add    $0xffffffff,%ebx
jne    1140 <calcFuncCall+0x20>
add    $0x1,%ebp
cmp    $0x2710,%ebp
jne    1130 <calcFuncCall+0x10>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rcx
sub    %r14,%rcx
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
test   %esi,%esi
jle    118c <calcFuncCall+0x6c>
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
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i32 0
define i64 @calcFuncCall() {
%1 = tail call i64 (...) @clock()
br label %2
2: ; preds = %0, %9
%3 = phi i32 [ 0, %0 ], [ %10, %9 ]
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %7, %4 ]
%6 = tail call i32 (...) @foo()
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 10000
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 10000
br i1 %11, label %12, label %2
12: ; preds = %9
%13 = tail call i64 (...) @clock()
%14 = sub nsw i64 %13, %1
%15 = load i32, i32* @CLOCKS_PER_SEC
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = udiv i32 1000, %15
%19 = icmp ugt i32 %15, 1000
%20 = select i1 %19, i32 1, i32 %18
%21 = zext i32 %20 to i64
%22 = mul nsw i64 %14, %21
br label %23
23: ; preds = %17, %12
%24 = phi i64 [ %22, %17 ], [ %14, %12 ]
ret i64 %24
}