#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 calcShift(void) {
  long stTim, endTim;
  int i, j;
  int a, b;
  stTim = clock();
  a = 0;
  b = 1;
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      a <<= b;
    }
    a = 0;
  }
  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):
<calcShift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1187 <calcShift+0x77>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    1172 <calcShift+0x62>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <calcShift+0x3c>
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <calcShift+0x28>
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    0x2e40(%rip),%rax
cmpl   $0x0,(%rax)
jle    11df <calcShift+0xcf>
mov    $0x3e8,%eax
mov    0x2e2b(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11da <calcShift+0xca>
movslq -0x24(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11df <calcShift+0xcf>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcShift>:
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 <calcShift+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 @calcShift() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i64 (...) @clock()
store i64 %8, i64* %1
store i32 0, i32* %5
store i32 1, i32* %6
store i32 0, i32* %3
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10000
br i1 %11, label %12, label %27
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %20, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 10000
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = shl i32 %18, %17
store i32 %19, i32* %5
br label %20
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %13
23: ; preds = %13
store i32 0, i32* %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 %9
27: ; preds = %9
%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* %7
%37 = load i32, i32* %7
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = load i32, i32* %7
%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 @calcShift() {
%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
}