#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int N = 100000000;
  clock_t begin, end;
  begin = clock();
  int sum = 0;
  int i;
  int j;
  for (j = 0; j <= 5; ++j)
    for (i = 0; i <= N; ++i)
      sum += i;
  end = clock();
  printf("my_test over, time consumed %d ms\n",
         (int)((double)(end - begin) / CLOCKS_PER_SEC * 1000));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5f5e100,-0x14(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jg     119d <main+0x7d>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     118a <main+0x6a>
mov    -0x30(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1167 <main+0x47>
jmp    118f <main+0x6f>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1156 <main+0x36>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e2c(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe38(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2ea7(%rip),%rax
divsd  (%rax),%xmm0
mulsd  0xeb3(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"my_test over, time consumed %d ms\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100000000, i32* %6
%12 = call i64 (...) @clock()
store i64 %12, i64* %7
store i32 0, i32* %9
store i32 0, i32* %11
br label %13
13: ; preds = %29, %2
%14 = load i32, i32* %11
%15 = icmp sle i32 %14, 5
br i1 %15, label %16, label %32
16: ; preds = %13
store i32 0, i32* %10
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %6
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %10
%23 = load i32, i32* %9
%24 = add nsw i32 %23, %22
store i32 %24, i32* %9
br label %25
25: ; preds = %21
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
store i32 %27, i32* %10
br label %17
28: ; preds = %17
br label %29
29: ; preds = %28
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %13
32: ; preds = %13
%33 = call i64 (...) @clock()
store i64 %33, i64* %8
%34 = load i64, i64* %8
%35 = load i64, i64* %7
%36 = sub nsw i64 %34, %35
%37 = sitofp i64 %36 to double
%38 = load double, double* @CLOCKS_PER_SEC
%39 = fdiv double %37, %38
%40 = fmul double %39, 1.000000e+03
%41 = fptosi double %40 to i32
%42 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"my_test over, time consumed %d ms\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @clock()
%4 = tail call i64 (...) @clock()
%5 = sub nsw i64 %4, %3
%6 = sitofp i64 %5 to double
%7 = load double, double* @CLOCKS_PER_SEC
%8 = fdiv double %6, %7
%9 = fmul double %8, 1.000000e+03
%10 = fptosi double %9 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}