#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 */
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ljmm_let_OS_take_care_1G_2G(int /*<<< orphan*/);
scalar_t__ mytest();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  ljmm_let_OS_take_care_1G_2G(0);
  pid_t pid = fork();
  if (pid < 0) {
    return 1;
  }
  if (pid) {
    int child_status;
    waitpid(pid, &child_status, 0);
    if (!WIFEXITED(child_status) || WEXITSTATUS(child_status) != 0) {
      fprintf(stderr, "child process does not exit normally\n");
      exit(1);
    }
  }
  exit(mytest() ? 0 : 1);
}


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)
xor    %edi,%edi
call   1030 <ljmm_let_OS_take_care_1G_2G@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    11be <main+0x3e>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret
cmpq   $0x0,-0x18(%rbp)
je     121f <main+0x9f>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x1c(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%eax
je     11fb <main+0x7b>
mov    -0x1c(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     121a <main+0x9a>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    121f <main+0x9f>
mov    $0x0,%al
call   1050 <mytest@plt>
mov    %rax,%rcx
mov    $0x1,%edi
xor    %eax,%eax
cmp    $0x0,%rcx
cmovne %eax,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1030 <ljmm_let_OS_take_care_1G_2G@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
jns    119b <main+0x1b>
mov    $0x1,%eax
pop    %rcx
ret
je     11c7 <main+0x47>
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    0x4(%rsp),%edi
call   1080 <WIFEXITED@plt>
test   %eax,%eax
je     11dc <main+0x5c>
mov    0x4(%rsp),%edi
call   1060 <WEXITSTATUS@plt>
test   %rax,%rax
jne    11dc <main+0x5c>
xor    %eax,%eax
call   1050 <mytest@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <exit@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"child process does not exit normally\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @ljmm_let_OS_take_care_1G_2G(i32 0)
%9 = call i64 (...) @fork()
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
ret i32 1
13: ; preds = %2
%14 = load i64, i64* %6
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = load i64, i64* %6
%18 = call i32 @waitpid(i64 %17, i32* %7, i32 0)
%19 = load i32, i32* %7
%20 = call i32 @WIFEXITED(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32, i32* %7
%24 = call i64 @WEXITSTATUS(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22, %16
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %22
br label %31
31: ; preds = %30, %13
%32 = call i64 (...) @mytest()
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 0, i32 1
%36 = call i32 @exit(i32 %35)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"child process does not exit normally\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @ljmm_let_OS_take_care_1G_2G(i32 0)
%5 = tail call i64 (...) @fork()
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
ret i32 1
8: ; preds = %2
%9 = icmp eq i64 %5, 0
br i1 %9, label %25, label %10
10: ; preds = %8
%11 = bitcast i32* %3 to i8*
%12 = call i32 @waitpid(i64 %5, i32* %3, i32 0)
%13 = load i32, i32* %3
%14 = call i32 @WIFEXITED(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i64 @WEXITSTATUS(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16, %10
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %16
br label %25
25: ; preds = %24, %8
%26 = call i64 (...) @mytest()
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @exit(i32 %28)
unreachable
}