#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 */
scalar_t__ WIFEXITED(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int wait(int *);
int main() {
  if (fork() == 0) {
    return 0;
  } else {
    int s;
    if (wait(&s) == -1) {
      perror("Unexpected error while setting up test "
             "pre-conditions");
      return -1;
    }
    if (WIFEXITED(s)) {
      printf("Test PASSED\n");
      return 0;
    }
  }
  printf("Test FAILED\n");
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    117c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <main+0x98>
lea    -0x8(%rbp),%rdi
call   1060 <wait@plt>
cmp    $0xffffffff,%eax
jne    11a6 <main+0x56>
lea    0xe6b(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <main+0x98>
mov    -0x8(%rbp),%edi
call   1050 <WIFEXITED@plt>
cmp    $0x0,%rax
je     11d0 <main+0x80>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <main+0x98>
jmp    11d5 <main+0x85>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     119f <main+0x4f>
lea    0xc(%rsp),%rdi
call   1060 <wait@plt>
cmp    $0xffffffff,%eax
je     11a7 <main+0x57>
mov    0xc(%rsp),%edi
call   1050 <WIFEXITED@plt>
test   %rax,%rax
je     118e <main+0x3e>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
jmp    119f <main+0x4f>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe52(%rip),%rdi
call   1040 <perror@plt>
jmp    119a <main+0x4a>

LLVM IR (-O0):
@.str = [54 x i8] c"Unexpected error while setting up test pre-conditions\00"
@.str.1 = [13 x i8] c"Test PASSED\0A\00"
@.str.2 = [13 x i8] c"Test FAILED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 0, i32* %1
br label %20
6: ; preds = %0
%7 = call i32 @wait(i32* %2)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
11: ; preds = %6
%12 = load i32, i32* %2
%13 = call i64 @WIFEXITED(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %20
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
20: ; preds = %18, %15, %9, %5
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [54 x i8] c"Unexpected error while setting up test pre-conditions\00"
@str = [12 x i8] c"Test FAILED\00"
@str.3 = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %0
%5 = bitcast i32* %1 to i8*
%6 = call i32 @wait(i32* %1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %16
10: ; preds = %4
%11 = load i32, i32* %1
%12 = call i64 @WIFEXITED(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
br label %16
16: ; preds = %8, %14
%17 = phi i32 [ 0, %14 ], [ -1, %8 ]
br label %20
18: ; preds = %10
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %16, %0, %18
%21 = phi i32 [ -1, %18 ], [ 0, %0 ], [ %17, %16 ]
ret i32 %21
}