#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_cutime;
  int tms_cstime;
};

/* Variables and functions */
int /*<<< orphan*/ execvp(char *, char **);
int fork();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ times(struct tms *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  struct tms exTime;
  int pid;
  pid = fork();
  if (pid) {
    wait(NULL);
  } else {
    execvp(argv[1], argv + 1);
  }
  times(&exTime);
  printf("Time taken ( in ticks ) :%d ", exTime.tms_cutime + exTime.tms_cstime);
  return 0;
}


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    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1188 <main+0x38>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
jmp    119d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <execvp@plt>
lea    -0x18(%rbp),%rdi
call   1040 <times@plt>
mov    -0x18(%rbp),%esi
add    -0x14(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     116c <main+0x1c>
xor    %edi,%edi
call   1060 <wait@plt>
jmp    117c <main+0x2c>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %rbx,%rsi
call   1050 <execvp@plt>
lea    0x8(%rsp),%rdi
call   1040 <times@plt>
mov    0xc(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tms = type { i32, i32 }
@.str = [29 x i8] c"Time taken ( in ticks ) :%d \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tms
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @fork()
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @wait(i32* null)
br label %20
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = call i32 @execvp(i8* %16, i8** %18)
br label %20
20: ; preds = %13, %11
%21 = call i32 @times(%struct.tms* %6)
%22 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%25 = load i32, i32* %24
%26 = add nsw i32 %23, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
%struct.tms = type { i32, i32 }
@.str = [29 x i8] c"Time taken ( in ticks ) :%d \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.tms
%4 = bitcast %struct.tms* %3 to i8*
%5 = tail call i32 (...) @fork()
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @wait(i32* null)
br label %13
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @execvp(i8* %11, i8** %10)
br label %13
13: ; preds = %9, %7
%14 = call i32 @times(%struct.tms* %3)
%15 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = add nsw i32 %18, %16
%20 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}