#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 */

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ test(int);
int /*<<< orphan*/ warnx(char *);
int main(int argc, char *argv[]) {
  int nowait = 0;
  if (argc == 2 && !strcmp(argv[1], "-w")) {
    nowait = 1;
  } else if (argc != 1 && argc != 0) {
    warnx("usage: forktest [-w]");
    return 1;
  }
  warnx("Starting.");
  test(nowait);
  warnx("Complete.");
  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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1180 <main+0x50>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1180 <main+0x50>
movl   $0x1,-0x14(%rbp)
jmp    11b1 <main+0x81>
cmpl   $0x1,-0x8(%rbp)
je     11ac <main+0x7c>
cmpl   $0x0,-0x8(%rbp)
je     11ac <main+0x7c>
lea    0xe68(%rip),%rdi
call   1030 <warnx@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d8 <main+0xa8>
jmp    11b1 <main+0x81>
lea    0xe60(%rip),%rdi
call   1030 <warnx@plt>
mov    -0x14(%rbp),%edi
call   1050 <test@plt>
lea    0xe56(%rip),%rdi
call   1030 <warnx@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1151 <main+0x21>
mov    0x8(%rsi),%rdi
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ebx
test   %eax,%eax
jne    117b <main+0x4b>
jmp    1158 <main+0x28>
xor    %ebx,%ebx
cmp    $0x1,%edi
ja     1176 <main+0x46>
lea    0xeb9(%rip),%rdi
call   1030 <warnx@plt>
mov    %ebx,%edi
call   1050 <test@plt>
xor    %ebx,%ebx
lea    0xeae(%rip),%rdi
jmp    1182 <main+0x52>
mov    $0x1,%ebx
lea    0xe81(%rip),%rdi
call   1030 <warnx@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-w\00"
@.str.1 = [21 x i8] c"usage: forktest [-w]\00"
@.str.2 = [10 x i8] c"Starting.\00"
@.str.3 = [10 x i8] c"Complete.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %9
store i32 1, i32* %6
br label %25
16: ; preds = %9, %2
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @warnx(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %30
24: ; preds = %19, %16
br label %25
25: ; preds = %24, %15
%26 = call i32 @warnx(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %6
%28 = call i32 @test(i32 %27)
%29 = call i32 @warnx(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %25, %22
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"-w\00"
@.str.1 = [21 x i8] c"usage: forktest [-w]\00"
@.str.2 = [10 x i8] c"Starting.\00"
@.str.3 = [10 x i8] c"Complete.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %15
9: ; preds = %2
%10 = icmp ult i32 %0, 2
br i1 %10, label %11, label %15
11: ; preds = %4, %9
%12 = phi i32 [ 0, %9 ], [ 1, %4 ]
%13 = tail call i32 @warnx(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @test(i32 %12)
br label %15
15: ; preds = %9, %4, %11
%16 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %9 ]
%17 = phi i32 [ 0, %11 ], [ 1, %4 ], [ 1, %9 ]
%18 = tail call i32 @warnx(i8* %16)
ret i32 %17
}