#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 int clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
int EXIT_SUCCESS;
int clock();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  clock_t ticks1, ticks2;
  printf("CLOCKS PER SEC IS: %ld\n", CLOCKS_PER_SEC);
  ticks1 = clock();
  ticks2 = ticks1;
  while ((ticks2 - ticks1) < 1000000)
    ticks2 = clock();
  ticks2 = clock();
  printf("clocks spent on sleeping : %ld\n", ticks2 - ticks1);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%esi
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cmp    $0xf4240,%eax
jge    117b <main+0x5b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x18(%rbp)
jmp    115b <main+0x3b>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
sub    -0x14(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    (%rax),%esi
lea    0xecf(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebx
nop
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
cmp    $0xf4240,%eax
jl     1140 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
lea    0xeb8(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"CLOCKS PER SEC IS: %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.1 = [32 x i8] c"clocks spent on sleeping : %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @CLOCKS_PER_SEC
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @clock()
store i32 %10, i32* %6
%11 = load i32, i32* %6
store i32 %11, i32* %7
br label %12
12: ; preds = %17, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = sub nsw i32 %13, %14
%16 = icmp slt i32 %15, 1000000
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 (...) @clock()
store i32 %18, i32* %7
br label %12
19: ; preds = %12
%20 = call i32 (...) @clock()
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = sub nsw i32 %21, %22
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}

LLVM IR (-O2):
@.str = [24 x i8] c"CLOCKS PER SEC IS: %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.1 = [32 x i8] c"clocks spent on sleeping : %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @CLOCKS_PER_SEC
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @clock()
br label %6
6: ; preds = %2, %6
%7 = tail call i32 (...) @clock()
%8 = sub nsw i32 %7, %5
%9 = icmp slt i32 %8, 1000000
br i1 %9, label %6, label %10
10: ; preds = %6
%11 = tail call i32 (...) @clock()
%12 = sub nsw i32 %11, %5
%13 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @EXIT_SUCCESS
ret i32 %14
}