#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 time_t;
struct tms {
  int tms_cutime;
  int tms_cstime;
};

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ execvp(char const *, char **);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printt(char *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int *);
int /*<<< orphan*/ times(struct tms *);
int wait(int *);
int main(int argc, const char *argv[]) {
  struct tms buffer, obuffer;
  int status;
  register int p;
  time_t before, after;
  if (argc <= 1)
    exit(0);
  time(&before);
  p = fork();
  if (p == -1) {
    fputs("Try again.\n", stderr);
    exit(1);
  }
  if (p == 0) {
    execvp(argv[1], (char **)&argv[1]);
    perror(argv[1]);
    _exit(1);
  }
  signal(SIGINT, SIG_IGN);
  signal(SIGQUIT, SIG_IGN);
  times(&obuffer);
  while (wait(&status) != p)
    times(&obuffer);
  time(&after);
  if ((status & 0377) != 0)
    fputs("Command terminated abnormally.\n", stderr);
  times(&buffer);
  fprintf(stderr, "\n");
  printt("real", (after - before) * 60);
  printt("user", buffer.tms_cutime - obuffer.tms_cutime);
  printt("sys ", buffer.tms_cstime - obuffer.tms_cstime);
  exit(status >> 8);
}


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)
cmpl   $0x1,-0x8(%rbp)
jg     11e7 <main+0x27>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    -0x2c(%rbp),%rdi
call   1080 <time@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1223 <main+0x63>
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
lea    0xdec(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1259 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   10b0 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
lea    -0x20(%rbp),%rdi
call   1090 <times@plt>
lea    -0x24(%rbp),%rdi
call   10d0 <wait@plt>
cmp    -0x28(%rbp),%eax
je     12b0 <main+0xf0>
lea    -0x20(%rbp),%rdi
call   1090 <times@plt>
jmp    1290 <main+0xd0>
lea    -0x30(%rbp),%rdi
call   1080 <time@plt>
mov    -0x24(%rbp),%eax
and    $0xff,%eax
cmp    $0x0,%eax
je     12df <main+0x11f>
mov    0x2cf7(%rip),%rax
mov    (%rax),%esi
lea    0xd32(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x18(%rbp),%rdi
call   1090 <times@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%eax
sub    -0x2c(%rbp),%eax
imul   $0x3c,%eax,%esi
lea    0xd1f(%rip),%rdi
call   1030 <printt@plt>
mov    -0x18(%rbp),%esi
sub    -0x20(%rbp),%esi
lea    0xd12(%rip),%rdi
call   1030 <printt@plt>
mov    -0x14(%rbp),%esi
sub    -0x1c(%rbp),%esi
lea    0xd05(%rip),%rdi
call   1030 <printt@plt>
mov    -0x24(%rbp),%edi
sar    $0x8,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jg     11d6 <main+0x16>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    %rsi,%r14
lea    0x1c(%rsp),%rdi
call   1080 <time@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1215 <main+0x55>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1235 <main+0x75>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0x8(%r14),%rsi
mov    0x8(%r14),%rdi
call   10b0 <execvp@plt>
mov    0x8(%r14),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
mov    0x2d93(%rip),%rbx
mov    (%rbx),%esi
call   1060 <signal@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1060 <signal@plt>
lea    0x10(%rsp),%rdi
call   1090 <times@plt>
lea    0xc(%rsp),%rdi
call   10d0 <wait@plt>
cmp    %r15d,%eax
je     1295 <main+0xd5>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rbp
nop
mov    %rbx,%rdi
call   1090 <times@plt>
mov    %rbp,%rdi
call   10d0 <wait@plt>
cmp    %r15d,%eax
jne    1280 <main+0xc0>
lea    0x18(%rsp),%rdi
call   1080 <time@plt>
cmpb   $0x0,0xc(%rsp)
je     12bb <main+0xfb>
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
lea    0xd56(%rip),%rdi
call   1050 <fputs@plt>
lea    0x20(%rsp),%rdi
call   1090 <times@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x18(%rsp),%eax
sub    0x1c(%rsp),%eax
imul   $0x3c,%eax,%esi
lea    0xd40(%rip),%rdi
call   1030 <printt@plt>
mov    0x20(%rsp),%esi
sub    0x10(%rsp),%esi
lea    0xd31(%rip),%rdi
call   1030 <printt@plt>
mov    0x24(%rsp),%esi
sub    0x14(%rsp),%esi
lea    0xd22(%rip),%rdi
call   1030 <printt@plt>
mov    0xc(%rsp),%edi
sar    $0x8,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.tms = type { i32, i32 }
@.str = [12 x i8] c"Try again.\0A\00"
@stderr = global i32 0
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@SIGQUIT = global i32 0
@.str.1 = [32 x i8] c"Command terminated abnormally.\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"real\00"
@.str.4 = [5 x i8] c"user\00"
@.str.5 = [5 x i8] c"sys \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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = call i32 @time(i32* %10)
%18 = call i32 (...) @fork()
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = call i32 @execvp(i8* %31, i8** %33)
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @perror(i8* %37)
%39 = call i32 @_exit(i32 1)
unreachable
40: ; preds = %25
%41 = load i32, i32* @SIGINT
%42 = load i32, i32* @SIG_IGN
%43 = call i32 @signal(i32 %41, i32 %42)
%44 = load i32, i32* @SIGQUIT
%45 = load i32, i32* @SIG_IGN
%46 = call i32 @signal(i32 %44, i32 %45)
%47 = call i32 @times(%struct.tms* %7)
br label %48
48: ; preds = %52, %40
%49 = call i32 @wait(i32* %8)
%50 = load i32, i32* %9
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 @times(%struct.tms* %7)
br label %48
54: ; preds = %48
%55 = call i32 @time(i32* %11)
%56 = load i32, i32* %8
%57 = and i32 %56, 255
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59, %54
%63 = call i32 @times(%struct.tms* %6)
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%66 = load i32, i32* %11
%67 = load i32, i32* %10
%68 = sub nsw i32 %66, %67
%69 = mul nsw i32 %68, 60
%70 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %69)
%71 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%72 = load i32, i32* %71
%73 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 0
%74 = load i32, i32* %73
%75 = sub nsw i32 %72, %74
%76 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.tms, %struct.tms* %7, i32 0, i32 1
%80 = load i32, i32* %79
%81 = sub nsw i32 %78, %80
%82 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %81)
%83 = load i32, i32* %8
%84 = ashr i32 %83, 8
%85 = call i32 @exit(i32 %84)
unreachable
}

LLVM IR (-O2):
%struct.tms = type { i32, i32 }
@.str = [12 x i8] c"Try again.\0A\00"
@stderr = global i32 0
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@SIGQUIT = global i32 0
@.str.1 = [32 x i8] c"Command terminated abnormally.\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"real\00"
@.str.4 = [5 x i8] c"user\00"
@.str.5 = [5 x i8] c"sys \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.tms
%4 = alloca %struct.tms
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast %struct.tms* %3 to i8*
%9 = bitcast %struct.tms* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = icmp slt i32 %0, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = call i32 @time(i32* %6)
%18 = call i32 (...) @fork()
switch i32 %18, label %30 [
i32 -1, label %19
i32 0, label %23
]
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fputs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @execvp(i8* %25, i8** %24)
%27 = load i8*, i8** %24
%28 = call i32 @perror(i8* %27)
%29 = call i32 @_exit(i32 1)
unreachable
30: ; preds = %16
%31 = load i32, i32* @SIGINT
%32 = load i32, i32* @SIG_IGN
%33 = call i32 @signal(i32 %31, i32 %32)
%34 = load i32, i32* @SIGQUIT
%35 = load i32, i32* @SIG_IGN
%36 = call i32 @signal(i32 %34, i32 %35)
%37 = call i32 @times(%struct.tms* %4)
%38 = call i32 @wait(i32* %5)
%39 = icmp eq i32 %38, %18
br i1 %39, label %44, label %40
40: ; preds = %30, %40
%41 = call i32 @times(%struct.tms* %4)
%42 = call i32 @wait(i32* %5)
%43 = icmp eq i32 %42, %18
br i1 %43, label %44, label %40
44: ; preds = %40, %30
%45 = call i32 @time(i32* %7)
%46 = load i32, i32* %5
%47 = and i32 %46, 255
%48 = icmp eq i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %44
%50 = load i32, i32* @stderr
%51 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %49, %44
%53 = call i32 @times(%struct.tms* %3)
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%56 = load i32, i32* %7
%57 = load i32, i32* %6
%58 = sub nsw i32 %56, %57
%59 = mul nsw i32 %58, 60
%60 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 0
%64 = load i32, i32* %63
%65 = sub nsw i32 %62, %64
%66 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 1
%68 = load i32, i32* %67
%69 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 1
%70 = load i32, i32* %69
%71 = sub nsw i32 %68, %70
%72 = call i32 @printt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %5
%74 = ashr i32 %73, 8
%75 = call i32 @exit(i32 %74)
unreachable
}