#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*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int main() {
  pid_t pid;
  pid = fork();
  if (pid < 0) {
    printf("fail to fork\n");
    exit(1);
  } else if (pid == 0) {
    execl("./interp.sh", "interp", "arg1", "arg2", NULL);
    _exit(0);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    118b <main+0x3b>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11c3 <main+0x73>
lea    0xe71(%rip),%rdi
lea    0xe76(%rip),%rsi
lea    0xe76(%rip),%rdx
lea    0xe74(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <execl@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
jmp    11c8 <main+0x78>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jns    1173 <main+0x23>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jne    11a0 <main+0x50>
lea    0xe84(%rip),%rdi
lea    0xe89(%rip),%rsi
lea    0xe89(%rip),%rdx
lea    0xe87(%rip),%rcx
xor    %r8d,%r8d
call   1060 <execl@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"fail to fork\0A\00"
@.str.1 = [12 x i8] c"./interp.sh\00"
@.str.2 = [7 x i8] c"interp\00"
@.str.3 = [5 x i8] c"arg1\00"
@.str.4 = [5 x i8] c"arg2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* null)
%14 = call i32 @_exit(i32 0)
unreachable
15: ; preds = %9
br label %16
16: ; preds = %15
%17 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"./interp.sh\00"
@.str.2 = [7 x i8] c"interp\00"
@.str.3 = [5 x i8] c"arg1\00"
@.str.4 = [5 x i8] c"arg2\00"
@str = [13 x i8] c"fail to fork\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = icmp eq i64 %1, 0
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* null)
%10 = tail call i32 @_exit(i32 0)
unreachable
11: ; preds = %6
%12 = tail call i32 @exit(i32 0)
unreachable
}