#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*/ SIGABRT;
int /*<<< orphan*/ WIFEXITED(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int wait(int *);
int main() {
  if (fork() == 0) {
    raise(SIGABRT);
    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   1080 <fork@plt>
cmp    $0x0,%rax
jne    119a <main+0x3a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <main+0xa5>
lea    -0x8(%rbp),%rdi
call   1070 <wait@plt>
cmp    $0xffffffff,%eax
jne    11c4 <main+0x64>
lea    0xe4d(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1205 <main+0xa5>
mov    -0x8(%rbp),%edi
call   1060 <WIFEXITED@plt>
cmp    $0x0,%eax
jne    11ed <main+0x8d>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <main+0xa5>
jmp    11f2 <main+0x92>
lea    0xe4a(%rip),%rdi
call   1040 <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   1080 <fork@plt>
test   %rax,%rax
je     11a2 <main+0x42>
lea    0xc(%rsp),%rdi
call   1070 <wait@plt>
cmp    $0xffffffff,%eax
je     11c8 <main+0x68>
mov    0xc(%rsp),%edi
call   1060 <WIFEXITED@plt>
test   %eax,%eax
je     11b2 <main+0x52>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
jmp    11c0 <main+0x60>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
jmp    11c0 <main+0x60>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe31(%rip),%rdi
call   1050 <perror@plt>
jmp    119b <main+0x3b>

LLVM IR (-O0):
@SIGABRT = global i32 0
@.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 %8
5: ; preds = %0
%6 = load i32, i32* @SIGABRT
%7 = call i32 @raise(i32 %6)
store i32 0, i32* %1
br label %22
8: ; preds = %0
%9 = call i32 @wait(i32* %2)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %22
13: ; preds = %8
%14 = load i32, i32* %2
%15 = call i32 @WIFEXITED(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = 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 %22
19: ; preds = %13
br label %20
20: ; preds = %19
%21 = 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 %22
22: ; preds = %20, %17, %11, %5
%23 = load i32, i32* %1
ret i32 %23
}

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