#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 tms_utime;
  int tms_stime;
  int tms_cutime;
  int tms_cstime;
};
typedef int clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ _SC_CLK_TCK;
int clock();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ killtime();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int sysconf(int /*<<< orphan*/);
int times(struct tms *);
int main(int argc, char *argv[]) {
  struct tms processTimes;
  clock_t startTime = clock();
  clock_t endTime;
  printf("%ld\n", sysconf(_SC_CLK_TCK));
  printf("CLOCKS PER SEC: %ld\n", CLOCKS_PER_SEC);
  killtime();
  if (times(&processTimes) == -1) {
    do {
      perror("times");
      exit(EXIT_FAILURE);
    } while (0);
  }
  printf("user time = %ld\n", processTimes.tms_utime);
  printf("system time = %ld\n", processTimes.tms_stime);
  printf("child user time = %ld\n", processTimes.tms_cutime);
  printf("child system time = %ld\n", processTimes.tms_cstime);
  endTime = clock();
  startTime = endTime;
  printf("Total time elapsed = %ld\n", endTime - startTime);
  printf("Final clock value = %ld\n", clock() / CLOCKS_PER_SEC);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,%esi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <killtime@plt>
lea    -0x20(%rbp),%rdi
call   1060 <times@plt>
cmp    $0xffffffff,%eax
jne    11f9 <main+0x89>
jmp    11df <main+0x6f>
lea    0xe2f(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%esi
sub    -0x24(%rbp),%esi
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    0x2d83(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,%esi
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <clock@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2e49(%rip),%rbx
mov    (%rbx),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <killtime@plt>
mov    %rsp,%rdi
call   1060 <times@plt>
cmp    $0xffffffff,%eax
je     123c <main+0xcc>
mov    (%rsp),%esi
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
lea    0xe3d(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
cltd
idivl  (%rbx)
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xdd2(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.tms = type { i32, i32, i32, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@_SC_CLK_TCK = global i32 0
@.str.1 = [21 x i8] c"CLOCKS PER SEC: %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [6 x i8] c"times\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [17 x i8] c"user time = %ld\0A\00"
@.str.4 = [19 x i8] c"system time = %ld\0A\00"
@.str.5 = [23 x i8] c"child user time = %ld\0A\00"
@.str.6 = [25 x i8] c"child system time = %ld\0A\00"
@.str.7 = [26 x i8] c"Total time elapsed = %ld\0A\00"
@.str.8 = [25 x i8] c"Final clock value = %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 %struct.tms
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @clock()
store i32 %9, i32* %7
%10 = load i32, i32* @_SC_CLK_TCK
%11 = call i32 @sysconf(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @CLOCKS_PER_SEC
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @killtime()
%16 = call i32 @times(%struct.tms* %6)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %2
br label %19
19: ; preds = %18
%20 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; No predecessors!
br label %24
24: ; preds = %23, %2
%25 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 2
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 3
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %35)
%37 = call i32 (...) @clock()
store i32 %37, i32* %8
%38 = load i32, i32* %8
store i32 %38, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = sub nsw i32 %39, %40
%42 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %41)
%43 = call i32 (...) @clock()
%44 = load i32, i32* @CLOCKS_PER_SEC
%45 = sdiv i32 %43, %44
%46 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
%struct.tms = type { i32, i32, i32, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@_SC_CLK_TCK = global i32 0
@.str.1 = [21 x i8] c"CLOCKS PER SEC: %ld\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [6 x i8] c"times\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [17 x i8] c"user time = %ld\0A\00"
@.str.4 = [19 x i8] c"system time = %ld\0A\00"
@.str.5 = [23 x i8] c"child user time = %ld\0A\00"
@.str.6 = [25 x i8] c"child system time = %ld\0A\00"
@.str.7 = [26 x i8] c"Total time elapsed = %ld\0A\00"
@.str.8 = [25 x i8] c"Final clock value = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.tms
%4 = bitcast %struct.tms* %3 to i8*
%5 = tail call i32 (...) @clock()
%6 = load i32, i32* @_SC_CLK_TCK
%7 = tail call i32 @sysconf(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @CLOCKS_PER_SEC
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 (...) @killtime()
%12 = call i32 @times(%struct.tms* %3)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 1
%23 = load i32, i32* %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 2
%26 = load i32, i32* %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 3
%29 = load i32, i32* %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = tail call i32 (...) @clock()
%32 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 0)
%33 = tail call i32 (...) @clock()
%34 = load i32, i32* @CLOCKS_PER_SEC
%35 = sdiv i32 %33, %34
%36 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}