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

/* Variables and functions */
int /*<<< orphan*/ _SC_CLK_TCK;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double);
int sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
scalar_t__ times(struct tms *);
int main(int argc, char *argv[]) {
  struct tms starttms, endtms;
  clock_t clocks;
  int clk_per_sec;
  int i;
  clk_per_sec = sysconf(_SC_CLK_TCK);
  if (clk_per_sec < 0) {
    perror("sysconf error.");
    return -1;
  }
  clocks = times(&starttms);
  if (clocks == (clock_t)-1) {
    perror("times error.");
    return -1;
  }
  for (i = 0; i < 10; i++)
    system("date");
  clocks = times(&endtms);
  if (clocks == (clock_t)-1) {
    perror("times error.");
    return -1;
  }
  printf("user time:		%f\n",
         (endtms.tms_utime - starttms.tms_utime) * 1.0 / clk_per_sec);
  printf("system time:		%f\n",
         (endtms.tms_stime - starttms.tms_stime) * 1.0 / clk_per_sec);
  printf("child user time:	%f\n",
         (endtms.tms_cutime - starttms.tms_cutime) * 1.0 / clk_per_sec);
  printf("child system time:	%f\n",
         (endtms.tms_cstime - starttms.tms_cstime) * 1.0 / clk_per_sec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1199 <main+0x49>
lea    0xe80(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <main+0x187>
lea    -0x30(%rbp),%rdi
call   1050 <times@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0xffffffffffffffff,-0x58(%rbp)
jne    11c9 <main+0x79>
lea    0xe5f(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <main+0x187>
movl   $0x0,-0x60(%rbp)
cmpl   $0xa,-0x60(%rbp)
jge    11f4 <main+0xa4>
lea    0xe43(%rip),%rdi
call   1030 <system@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11d0 <main+0x80>
lea    -0x50(%rbp),%rdi
call   1050 <times@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0xffffffffffffffff,-0x58(%rbp)
jne    1224 <main+0xd4>
lea    0xe04(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <main+0x187>
movsd  -0x50(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xdca(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x48(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xd9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xd74(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xdab(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xd49(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd95(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
test   %eax,%eax
js     127b <main+0x12b>
mov    %eax,%ebp
lea    0x28(%rsp),%rdi
call   1050 <times@plt>
cmp    $0xffffffffffffffff,%rax
je     1272 <main+0x122>
lea    0xe93(%rip),%rbx
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0x8(%rsp),%rdi
call   1050 <times@plt>
cmp    $0xffffffffffffffff,%rax
je     1272 <main+0x122>
movsd  0x8(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
cvtsi2sd %ebp,%xmm1
movsd  %xmm1,(%rsp)
divsd  %xmm1,%xmm0
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
divsd  (%rsp),%xmm0
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
divsd  (%rsp),%xmm0
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
subsd  0x40(%rsp),%xmm0
divsd  (%rsp),%xmm0
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xd96(%rip),%rdi
jmp    1282 <main+0x132>
lea    0xd7e(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    126b <main+0x11b>

LLVM IR (-O0):
%struct.tms = type { double, double, double, double }
@_SC_CLK_TCK = global i32 0
@.str = [15 x i8] c"sysconf error.\00"
@.str.1 = [13 x i8] c"times error.\00"
@.str.2 = [5 x i8] c"date\00"
@.str.3 = [16 x i8] c"user time:\09\09%f\0A\00"
@.str.4 = [18 x i8] c"system time:\09\09%f\0A\00"
@.str.5 = [21 x i8] c"child user time:\09%f\0A\00"
@.str.6 = [23 x i8] c"child system time:\09%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tms
%7 = alloca %struct.tms
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @_SC_CLK_TCK
%12 = call i32 @sysconf(i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %79
17: ; preds = %2
%18 = call i64 @times(%struct.tms* %6)
store i64 %18, i64* %8
%19 = load i64, i64* %8
%20 = icmp eq i64 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %79
23: ; preds = %17
store i32 0, i32* %10
br label %24
24: ; preds = %29, %23
%25 = load i32, i32* %10
%26 = icmp slt i32 %25, 10
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %24
32: ; preds = %24
%33 = call i64 @times(%struct.tms* %7)
store i64 %33, i64* %8
%34 = load i64, i64* %8
%35 = icmp eq i64 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %79
38: ; preds = %32
%39 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 0
%40 = load double, double* %39
%41 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%42 = load double, double* %41
%43 = fsub double %40, %42
%44 = fmul double %43, 1.000000e+00
%45 = load i32, i32* %9
%46 = sitofp i32 %45 to double
%47 = fdiv double %44, %46
%48 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %47)
%49 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 1
%50 = load double, double* %49
%51 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%52 = load double, double* %51
%53 = fsub double %50, %52
%54 = fmul double %53, 1.000000e+00
%55 = load i32, i32* %9
%56 = sitofp i32 %55 to double
%57 = fdiv double %54, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %57)
%59 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 2
%60 = load double, double* %59
%61 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 2
%62 = load double, double* %61
%63 = fsub double %60, %62
%64 = fmul double %63, 1.000000e+00
%65 = load i32, i32* %9
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %67)
%69 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 3
%70 = load double, double* %69
%71 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 3
%72 = load double, double* %71
%73 = fsub double %70, %72
%74 = fmul double %73, 1.000000e+00
%75 = load i32, i32* %9
%76 = sitofp i32 %75 to double
%77 = fdiv double %74, %76
%78 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %77)
store i32 0, i32* %3
br label %79
79: ; preds = %38, %36, %21, %15
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
%struct.tms = type { double, double, double, double }
@_SC_CLK_TCK = global i32 0
@.str = [15 x i8] c"sysconf error.\00"
@.str.1 = [13 x i8] c"times error.\00"
@.str.2 = [5 x i8] c"date\00"
@.str.3 = [16 x i8] c"user time:\09\09%f\0A\00"
@.str.4 = [18 x i8] c"system time:\09\09%f\0A\00"
@.str.5 = [21 x i8] c"child user time:\09%f\0A\00"
@.str.6 = [23 x i8] c"child system time:\09%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.tms
%4 = alloca %struct.tms
%5 = bitcast %struct.tms* %3 to i8*
%6 = bitcast %struct.tms* %4 to i8*
%7 = load i32, i32* @_SC_CLK_TCK
%8 = tail call i32 @sysconf(i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %62
12: ; preds = %2
%13 = call i64 @times(%struct.tms* %3)
%14 = icmp eq i64 %13, -1
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = call i64 @times(%struct.tms* %4)
%27 = icmp eq i64 %26, -1
br i1 %27, label %30, label %32
28: ; preds = %12
%29 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %62
30: ; preds = %15
%31 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %62
32: ; preds = %15
%33 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 0
%34 = load double, double* %33
%35 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%36 = load double, double* %35
%37 = fsub double %34, %36
%38 = sitofp i32 %8 to double
%39 = fdiv double %37, %38
%40 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %39)
%41 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 1
%42 = load double, double* %41
%43 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 1
%44 = load double, double* %43
%45 = fsub double %42, %44
%46 = fdiv double %45, %38
%47 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %46)
%48 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 2
%49 = load double, double* %48
%50 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 2
%51 = load double, double* %50
%52 = fsub double %49, %51
%53 = fdiv double %52, %38
%54 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %53)
%55 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 3
%56 = load double, double* %55
%57 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 3
%58 = load double, double* %57
%59 = fsub double %56, %58
%60 = fdiv double %59, %38
%61 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), double %60)
br label %62
62: ; preds = %32, %30, %28, %10
%63 = phi i32 [ -1, %10 ], [ -1, %28 ], [ -1, %30 ], [ 0, %32 ]
ret i32 %63
}