#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*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ run();
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  signal(SIGPIPE, SIG_IGN);
  pid_t pid;
  if ((pid = fork()) < 0) {
    printf("End at: %d", 37);
    exit(-1);
  }
  if (pid) {
    printf("End at: %d", 42);
    exit(0);
  }
  run();
  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)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    11ad <main+0x5d>
lea    0xe67(%rip),%rdi
mov    $0x25,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
je     11d0 <main+0x80>
lea    0xe41(%rip),%rdi
mov    $0x2a,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1030 <run@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1181 <main+0x31>
jne    119c <main+0x4c>
xor    %eax,%eax
call   1030 <run@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe78(%rip),%rdi
mov    $0x25,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
lea    0xe5d(%rip),%rdi
mov    $0x2a,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str = [11 x i8] c"End at: %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @SIGPIPE
%8 = load i32, i32* @SIG_IGN
%9 = call i32 @signal(i32 %7, i32 %8)
%10 = call i64 (...) @fork()
store i64 %10, i64* %6
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 37)
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = load i64, i64* %6
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 42)
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %15
%22 = call i32 (...) @run()
ret i32 0
}

LLVM IR (-O2):
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str = [11 x i8] c"End at: %d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @SIGPIPE
%4 = load i32, i32* @SIG_IGN
%5 = tail call i32 @signal(i32 %3, i32 %4)
%6 = tail call i64 (...) @fork()
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 37)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = icmp eq i64 %6, 0
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 42)
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %11
%17 = tail call i32 (...) @run()
ret i32 0
}