#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 */
struct tms {
  int /*<<< orphan*/ tms_cstime;
  int /*<<< orphan*/ tms_cutime;
  int /*<<< orphan*/ tms_stime;
  int /*<<< orphan*/ tms_utime;
};
typedef int /*<<< orphan*/ i;

/* Variables and functions */
int /*<<< orphan*/ CLOCKS_PER_SEC;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ _SC_CLK_TCK;
int /*<<< orphan*/ clock();
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ times(struct tms *);
int /*<<< orphan*/ write(int, long *, int);
int main() {
  struct tms tmsbuf;
  long i;
  double x;
  int fd;
  printf("clock ticks %ld\n", sysconf(_SC_CLK_TCK));
  printf("CLOCKS_PER_SEC %ld\n", CLOCKS_PER_SEC);
  fd = open("/dev/null", O_RDWR);
  for (i = 0; i < 10000000; i++) {
    write(fd, &i, sizeof(i));
  }
  close(fd);
  times(&tmsbuf);
  printf("utime = %ld\n", tmsbuf.tms_utime);
  printf("stime = %ld\n", tmsbuf.tms_stime);
  printf("cutime = %ld\n", tmsbuf.tms_cutime);
  printf("cstime = %ld\n", tmsbuf.tms_cstime);
  printf("clock = %ld\n", clock());
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    0xe65(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x989680,-0x20(%rbp)
jge    1200 <main+0x90>
mov    -0x2c(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11d0 <main+0x60>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
lea    -0x18(%rbp),%rdi
call   1080 <times@plt>
mov    -0xc(%rbp),%esi
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdf5(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
lea    0xe73(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
lea    0xe6c(%rip),%rdi
call   1070 <open@plt>
mov    %eax,%ebp
movq   $0x0,0x8(%rsp)
mov    $0x1,%ebx
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    %rbx,0x8(%rsp)
add    $0x1,%rbx
cmp    $0x989681,%rbx
jne    11e0 <main+0x70>
mov    %ebp,%edi
call   1060 <close@plt>
lea    0x10(%rsp),%rdi
call   1080 <times@plt>
mov    0x1c(%rsp),%esi
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
lea    0xdeb(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tms = type { i32, i32, i32, i32 }
@.str = [17 x i8] c"clock ticks %ld\0A\00"
@_SC_CLK_TCK = global i32 0
@.str.1 = [20 x i8] c"CLOCKS_PER_SEC %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.3 = [13 x i8] c"utime = %ld\0A\00"
@.str.4 = [13 x i8] c"stime = %ld\0A\00"
@.str.5 = [14 x i8] c"cutime = %ld\0A\00"
@.str.6 = [14 x i8] c"cstime = %ld\0A\00"
@.str.7 = [13 x i8] c"clock = %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tms
%3 = alloca i64
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @_SC_CLK_TCK
%7 = call i32 @sysconf(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @CLOCKS_PER_SEC
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11)
store i32 %12, i32* %5
store i64 0, i64* %3
br label %13
13: ; preds = %19, %0
%14 = load i64, i64* %3
%15 = icmp slt i64 %14, 10000000
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %5
%18 = call i32 @write(i32 %17, i64* %3, i32 8)
br label %19
19: ; preds = %16
%20 = load i64, i64* %3
%21 = add nsw i64 %20, 1
store i64 %21, i64* %3
br label %13
22: ; preds = %13
%23 = load i32, i32* %5
%24 = call i32 @close(i32 %23)
%25 = call i32 @times(%struct.tms* %2)
%26 = getelementptr inbounds %struct.tms, %struct.tms* %2, i32 0, i32 3
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.tms, %struct.tms* %2, i32 0, i32 2
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.tms, %struct.tms* %2, i32 0, i32 1
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.tms, %struct.tms* %2, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %36)
%38 = call i32 (...) @clock()
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
%struct.tms = type { i32, i32, i32, i32 }
@.str = [17 x i8] c"clock ticks %ld\0A\00"
@_SC_CLK_TCK = global i32 0
@.str.1 = [20 x i8] c"CLOCKS_PER_SEC %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.3 = [13 x i8] c"utime = %ld\0A\00"
@.str.4 = [13 x i8] c"stime = %ld\0A\00"
@.str.5 = [14 x i8] c"cutime = %ld\0A\00"
@.str.6 = [14 x i8] c"cstime = %ld\0A\00"
@.str.7 = [13 x i8] c"clock = %ld\0A\00"
define i32 @main() {
%1 = alloca %struct.tms
%2 = alloca i64
%3 = bitcast %struct.tms* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = load i32, i32* @_SC_CLK_TCK
%6 = tail call i32 @sysconf(i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @CLOCKS_PER_SEC
%9 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @O_RDWR
%11 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %10)
store i64 0, i64* %2
br label %12
12: ; preds = %0, %12
%13 = phi i64 [ 0, %0 ], [ %15, %12 ]
%14 = call i32 @write(i32 %11, i64* %2, i32 8)
%15 = add nuw nsw i64 %13, 1
store i64 %15, i64* %2
%16 = icmp eq i64 %15, 10000000
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = tail call i32 @close(i32 %11)
%19 = call i32 @times(%struct.tms* %1)
%20 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 3
%21 = load i32, i32* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 2
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 1
%27 = load i32, i32* %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 0
%30 = load i32, i32* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = tail call i32 (...) @clock()
%33 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %32)
ret i32 0
}