#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  pid_t pid;
  puts("Begin!");
  fflush(NULL);
  pid = fork();
  if (pid < 0) {
    perror("fork()");
    exit(1);
  }
  if (pid == 0) {
    execl("/bin/sh", "sh", "-c", "date +%s", NULL);
    perror("execl()");
    exit(1);
  }
  wait(NULL);
  puts("End!");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    11c0 <main+0x50>
lea    0xe56(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1207 <main+0x97>
lea    0xe3c(%rip),%rdi
lea    0xe3a(%rip),%rsi
lea    0xe36(%rip),%rdx
lea    0xe32(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <execl@plt>
lea    0xe2a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <wait@plt>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <fflush@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
jns    1199 <main+0x29>
lea    0xe70(%rip),%rdi
jmp    11c6 <main+0x56>
jne    11d5 <main+0x65>
lea    0xe6c(%rip),%rdi
lea    0xe6a(%rip),%rsi
lea    0xe66(%rip),%rdx
lea    0xe62(%rip),%rcx
xor    %r8d,%r8d
call   1070 <execl@plt>
lea    0xe5c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1080 <wait@plt>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Begin!\00"
@.str.1 = [7 x i8] c"fork()\00"
@.str.2 = [8 x i8] c"/bin/sh\00"
@.str.3 = [3 x i8] c"sh\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [9 x i8] c"date +%s\00"
@.str.6 = [8 x i8] c"execl()\00"
@.str.7 = [5 x i8] c"End!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @fflush(i32* null)
%5 = call i64 (...) @fork()
store i64 %5, i64* %2
%6 = load i64, i64* %2
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i64, i64* %2
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* null)
%16 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %11
%19 = call i32 @wait(i32* null)
%20 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"Begin!\00"
@.str.1 = [7 x i8] c"fork()\00"
@.str.2 = [8 x i8] c"/bin/sh\00"
@.str.3 = [3 x i8] c"sh\00"
@.str.4 = [3 x i8] c"-c\00"
@.str.5 = [9 x i8] c"date +%s\00"
@.str.6 = [8 x i8] c"execl()\00"
@.str.7 = [5 x i8] c"End!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @fflush(i32* null)
%3 = tail call i64 (...) @fork()
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = icmp eq i64 %3, 0
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* null)
%12 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
%15 = tail call i32 @wait(i32* null)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
}