#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 dummy;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printProcessInfo(int, int);
int /*<<< orphan*/ printTimes(struct tms);
int /*<<< orphan*/ printf(char *, int);
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ times(struct tms *);
int /*<<< orphan*/ wait(int *);
int main() {
  int childStatus = 0;
  time_t epochTime = time(NULL);
  struct tms strucTimes;
  printf("START: %d\n", epochTime);
  pid_t forkVal = fork();
  if (forkVal == -1) {
    perror("\nERROR: fork failed\n");
    return 1;
  } else if (forkVal == 0) {
    printProcessInfo(forkVal, childStatus);
    exit(7);
  } else {
    wait(&childStatus);
    printProcessInfo(forkVal, childStatus);
    times(&strucTimes);
    printTimes(strucTimes);
  }
  printf("STOP: %d\n", epochTime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ed <main+0x5d>
lea    0xe2f(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    124c <main+0xbc>
cmpl   $0x0,-0x14(%rbp)
jne    120c <main+0x7c>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <printProcessInfo@plt>
mov    $0x7,%edi
call   1090 <exit@plt>
lea    -0x8(%rbp),%rdi
call   10a0 <wait@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <printProcessInfo@plt>
lea    -0x10(%rbp),%rdi
call   1070 <times@plt>
mov    -0x10(%rbp),%edi
call   1060 <printTimes@plt>
jmp    1236 <main+0xa6>
mov    -0xc(%rbp),%esi
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebx
lea    0xe52(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
cmp    $0xffffffff,%eax
je     1206 <main+0x76>
mov    %eax,%ebp
test   %eax,%eax
je     1219 <main+0x89>
lea    0xc(%rsp),%rdi
call   10a0 <wait@plt>
mov    0xc(%rsp),%esi
mov    %ebp,%edi
call   1030 <printProcessInfo@plt>
lea    0x10(%rsp),%rdi
call   1070 <times@plt>
mov    0x10(%rsp),%edi
call   1060 <printTimes@plt>
lea    0xe2a(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdfe(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    11ff <main+0x6f>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <printProcessInfo@plt>
mov    $0x7,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.tms = type { i32 }
@.str = [11 x i8] c"START: %d\0A\00"
@.str.1 = [21 x i8] c"\0AERROR: fork failed\0A\00"
@.str.2 = [10 x i8] c"STOP: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tms
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @fork()
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %35
14: ; preds = %0
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %5
%19 = load i32, i32* %2
%20 = call i32 @printProcessInfo(i32 %18, i32 %19)
%21 = call i32 @exit(i32 7)
unreachable
22: ; preds = %14
%23 = call i32 @wait(i32* %2)
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = call i32 @printProcessInfo(i32 %24, i32 %25)
%27 = call i32 @times(%struct.tms* %4)
%28 = getelementptr inbounds %struct.tms, %struct.tms* %4, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i32 @printTimes(i32 %29)
br label %31
31: ; preds = %22
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %33)
store i32 0, i32* %1
br label %35
35: ; preds = %32, %12
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
%struct.tms = type { i32 }
@.str = [11 x i8] c"START: %d\0A\00"
@.str.1 = [21 x i8] c"\0AERROR: fork failed\0A\00"
@.str.2 = [10 x i8] c"STOP: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tms
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = tail call i32 @time(i32* null)
%5 = bitcast %struct.tms* %2 to i8*
%6 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
%7 = tail call i32 (...) @fork()
switch i32 %7, label %13 [
i32 -1, label %8
i32 0, label %10
]
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %22
10: ; preds = %0
%11 = tail call i32 @printProcessInfo(i32 0, i32 0)
%12 = tail call i32 @exit(i32 7)
unreachable
13: ; preds = %0
%14 = call i32 @wait(i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @printProcessInfo(i32 %7, i32 %15)
%17 = call i32 @times(%struct.tms* %2)
%18 = getelementptr inbounds %struct.tms, %struct.tms* %2, i64 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @printTimes(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %22
22: ; preds = %13, %8
%23 = phi i32 [ 1, %8 ], [ 0, %13 ]
ret i32 %23
}