#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*/ exit(int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int /*<<< orphan*/, int, int /*<<< orphan*/);
scalar_t__ getpid();
scalar_t__ getppid();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ wait(int *);
int main() {
  char buf[100];
  int childpid;
  int retval;
  int status;
  childpid = fork();
  if (childpid >= 0) {
    if (childpid == 0) {
      sprintf(buf, "<> <> CHILD: I am the child process!\n");
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "<> <> CHILD: Here's my PID: %d\n", (int)getpid());
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "<> <> CHILD: My parent's PID is: %d\n", (int)getppid());
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "<> <> CHILD: The value of my copy of childpid is: %d\n",
              childpid);
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "<> <> CHILD: Sleeping for 1 second...\n");
      fwrite(buf, strlen(buf), 1, stdout);
      sleep(1);
      sprintf(buf, "<> <> CHILD: Enter an exit value (0 to 255): ");
      fwrite(buf, strlen(buf), 1, stdout);
      scanf(" %d", &retval);
      sprintf(buf, "<> <> CHILD: Goodbye!\n");
      fwrite(buf, strlen(buf), 1, stdout);
      exit(retval);
    } else {
      sprintf(buf, "  #   PARENT: I am the parent process!\n");
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "  #   PARENT: Here's my PID: %d\n", (int)getpid());
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "  #   PARENT: The value of my copy of childpid is %d\n",
              childpid);
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "  #   PARENT: I will now wait for my child to exit.\n");
      fwrite(buf, strlen(buf), 1, stdout);
      wait(&status);
      sprintf(buf, "  #   PARENT: Child's exit code is: %d\n", status / 256);
      fwrite(buf, strlen(buf), 1, stdout);
      sprintf(buf, "  #   PARENT: Goodbye!\n");
      fwrite(buf, strlen(buf), 1, stdout);
      exit(0);
    }
  } else {
    fprintf(stderr, "Error: unsuccsseful fork\n");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     15c4 <main+0x414>
cmpl   $0x0,-0x74(%rbp)
jne    1401 <main+0x251>
lea    -0x70(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xc8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc8(%rbp),%rdi
mov    %eax,%esi
mov    0x2dc2(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc0(%rbp),%rdi
mov    %eax,%edx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%esi
mov    0x2d69(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    $0x0,%al
call   1080 <getppid@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%edx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%esi
mov    0x2d10(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%esi
mov    0x2ccb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rdi
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%esi
mov    0x2c89(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
lea    -0x70(%rbp),%rdi
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%esi
mov    0x2c3d(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    0xd48(%rip),%rdi
lea    -0x78(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x70(%rbp),%rdi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    %eax,%esi
mov    0x2beb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    -0x78(%rbp),%edi
call   1090 <exit@plt>
lea    -0x70(%rbp),%rdi
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x100(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x100(%rbp),%rdi
mov    %eax,%esi
mov    0x2ba1(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xf8(%rbp),%rdi
mov    %eax,%edx
lea    0xcd4(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xf0(%rbp),%rdi
mov    %eax,%esi
mov    0x2b48(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xcb0(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xe8(%rbp),%rdi
mov    %eax,%esi
mov    0x2b03(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rdi
lea    0xca4(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xe0(%rbp),%rdi
mov    %eax,%esi
mov    0x2ac1(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x7c(%rbp),%rdi
call   10c0 <wait@plt>
lea    -0x70(%rbp),%rdi
mov    -0x7c(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xc81(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xd8(%rbp),%rdi
mov    %eax,%esi
mov    0x2a69(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    -0x70(%rbp),%rdi
lea    0xc67(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xd0(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xd0(%rbp),%rdi
mov    %eax,%esi
mov    0x2a27(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2a15(%rip),%rax
mov    (%rax),%edi
lea    0xc31(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
js     138a <main+0x1da>
jne    13a6 <main+0x1f6>
movups 0xe39(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe1d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0xa21737365636f,%rax
mov    %rax,0x2e(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2dcd(%rip),%rbp
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
xor    %eax,%eax
call   1080 <getppid@plt>
lea    0xde7(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    0xddf(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
movabs $0xa2e2e2e646e6f,%rax
mov    %rax,0x2f(%rsp)
movups 0xdd9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xddd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%edi
call   10b0 <sleep@plt>
movups 0xdc4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xdc8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xdca(%rip),%xmm0
movups %xmm0,0x2e(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    0xdb4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
movabs $0xa21657962646f,%rax
mov    %rax,0x1f(%rsp)
movups 0xd98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    0xc(%rsp),%edi
call   1090 <exit@plt>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    %eax,%ebp
movups 0xd72(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xd56(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0xa21737365636f,%rax
mov    %rax,0x30(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2bf5(%rip),%r14
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xd36(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    0xd2a(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
movabs $0xa2e7469786520,%rax
mov    %rax,0x3d(%rsp)
movups 0xd24(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xd28(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xd2c(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
lea    0xc(%rsp),%rdi
call   10c0 <wait@plt>
mov    0xc(%rsp),%eax
lea    0xff(%rax),%edx
test   %eax,%eax
cmovns %eax,%edx
sar    $0x8,%edx
lea    0xcff(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
movabs $0xa21657962646f,%rax
mov    %rax,0x20(%rsp)
movups 0xced(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"<> <> CHILD: I am the child process!\0A\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"<> <> CHILD: Here's my PID: %d\0A\00"
@.str.2 = [37 x i8] c"<> <> CHILD: My parent's PID is: %d\0A\00"
@.str.3 = [54 x i8] c"<> <> CHILD: The value of my copy of childpid is: %d\0A\00"
@.str.4 = [39 x i8] c"<> <> CHILD: Sleeping for 1 second...\0A\00"
@.str.5 = [46 x i8] c"<> <> CHILD: Enter an exit value (0 to 255): \00"
@.str.6 = [4 x i8] c" %d\00"
@.str.7 = [23 x i8] c"<> <> CHILD: Goodbye!\0A\00"
@.str.8 = [40 x i8] c" # PARENT: I am the parent process!\0A\00"
@.str.9 = [33 x i8] c" # PARENT: Here's my PID: %d\0A\00"
@.str.10 = [54 x i8] c" # PARENT: The value of my copy of childpid is %d\0A\00"
@.str.11 = [53 x i8] c" # PARENT: I will now wait for my child to exit.\0A\00"
@.str.12 = [40 x i8] c" # PARENT: Child's exit code is: %d\0A\00"
@.str.13 = [24 x i8] c" # PARENT: Goodbye!\0A\00"
@stderr = global i32 0
@.str.14 = [26 x i8] c"Error: unsuccsseful fork\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @fork()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %121
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %71
12: ; preds = %9
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = load i32, i32* @stdout
%19 = call i32 @fwrite(i8* %15, i32 %17, i32 1, i32 %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i64 (...) @getpid()
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i8* %24, i32 %26, i32 1, i32 %27)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%30 = call i64 (...) @getppid()
%31 = trunc i64 %30 to i32
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = load i32, i32* @stdout
%37 = call i32 @fwrite(i8* %33, i32 %35, i32 1, i32 %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%39 = load i32, i32* %3
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = load i32, i32* @stdout
%45 = call i32 @fwrite(i8* %41, i32 %43, i32 1, i32 %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = load i32, i32* @stdout
%52 = call i32 @fwrite(i8* %48, i32 %50, i32 1, i32 %51)
%53 = call i32 @sleep(i32 1)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = load i32, i32* @stdout
%60 = call i32 @fwrite(i8* %56, i32 %58, i32 1, i32 %59)
%61 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%63 = call i32 (i8*, i8*, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%66 = call i32 @strlen(i8* %65)
%67 = load i32, i32* @stdout
%68 = call i32 @fwrite(i8* %64, i32 %66, i32 1, i32 %67)
%69 = load i32, i32* %4
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %9
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%73 = call i32 (i8*, i8*, ...) @sprintf(i8* %72, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = load i32, i32* @stdout
%78 = call i32 @fwrite(i8* %74, i32 %76, i32 1, i32 %77)
%79 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%80 = call i64 (...) @getpid()
%81 = trunc i64 %80 to i32
%82 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %81)
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%85 = call i32 @strlen(i8* %84)
%86 = load i32, i32* @stdout
%87 = call i32 @fwrite(i8* %83, i32 %85, i32 1, i32 %86)
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%89 = load i32, i32* %3
%90 = call i32 (i8*, i8*, ...) @sprintf(i8* %88, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %89)
%91 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
%94 = load i32, i32* @stdout
%95 = call i32 @fwrite(i8* %91, i32 %93, i32 1, i32 %94)
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %96, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
%98 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%99 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%100 = call i32 @strlen(i8* %99)
%101 = load i32, i32* @stdout
%102 = call i32 @fwrite(i8* %98, i32 %100, i32 1, i32 %101)
%103 = call i32 @wait(i32* %5)
%104 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%105 = load i32, i32* %5
%106 = sdiv i32 %105, 256
%107 = call i32 (i8*, i8*, ...) @sprintf(i8* %104, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i32 %106)
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%109 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%110 = call i32 @strlen(i8* %109)
%111 = load i32, i32* @stdout
%112 = call i32 @fwrite(i8* %108, i32 %110, i32 1, i32 %111)
%113 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* %113, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
%115 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%116 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%117 = call i32 @strlen(i8* %116)
%118 = load i32, i32* @stdout
%119 = call i32 @fwrite(i8* %115, i32 %117, i32 1, i32 %118)
%120 = call i32 @exit(i32 0)
unreachable
121: ; preds = %0
%122 = load i32, i32* @stderr
%123 = call i32 @fprintf(i32 %122, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
%124 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [38 x i8] c"<> <> CHILD: I am the child process!\0A\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"<> <> CHILD: Here's my PID: %d\0A\00"
@.str.2 = [37 x i8] c"<> <> CHILD: My parent's PID is: %d\0A\00"
@.str.3 = [54 x i8] c"<> <> CHILD: The value of my copy of childpid is: %d\0A\00"
@.str.4 = [39 x i8] c"<> <> CHILD: Sleeping for 1 second...\0A\00"
@.str.5 = [46 x i8] c"<> <> CHILD: Enter an exit value (0 to 255): \00"
@.str.6 = [4 x i8] c" %d\00"
@.str.7 = [23 x i8] c"<> <> CHILD: Goodbye!\0A\00"
@.str.8 = [40 x i8] c" # PARENT: I am the parent process!\0A\00"
@.str.9 = [33 x i8] c" # PARENT: Here's my PID: %d\0A\00"
@.str.10 = [54 x i8] c" # PARENT: The value of my copy of childpid is %d\0A\00"
@.str.11 = [53 x i8] c" # PARENT: I will now wait for my child to exit.\0A\00"
@.str.12 = [40 x i8] c" # PARENT: Child's exit code is: %d\0A\00"
@.str.13 = [24 x i8] c" # PARENT: Goodbye!\0A\00"
@stderr = global i32 0
@.str.14 = [26 x i8] c"Error: unsuccsseful fork\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (...) @fork()
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %72
9: ; preds = %0
%10 = icmp eq i32 %7, 0
br i1 %10, label %11, label %44
11: ; preds = %9
%12 = call i32 @strlen(i8* %4)
%13 = load i32, i32* @stdout
%14 = call i32 @fwrite(i8* %4, i32 %12, i32 1, i32 %13)
%15 = call i64 (...) @getpid()
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 @strlen(i8* %4)
%19 = load i32, i32* @stdout
%20 = call i32 @fwrite(i8* %4, i32 %18, i32 1, i32 %19)
%21 = call i64 (...) @getppid()
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @strlen(i8* %4)
%25 = load i32, i32* @stdout
%26 = call i32 @fwrite(i8* %4, i32 %24, i32 1, i32 %25)
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 0)
%28 = call i32 @strlen(i8* %4)
%29 = load i32, i32* @stdout
%30 = call i32 @fwrite(i8* %4, i32 %28, i32 1, i32 %29)
%31 = call i32 @strlen(i8* %4)
%32 = load i32, i32* @stdout
%33 = call i32 @fwrite(i8* %4, i32 %31, i32 1, i32 %32)
%34 = call i32 @sleep(i32 1)
%35 = call i32 @strlen(i8* %4)
%36 = load i32, i32* @stdout
%37 = call i32 @fwrite(i8* %4, i32 %35, i32 1, i32 %36)
%38 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%39 = call i32 @strlen(i8* %4)
%40 = load i32, i32* @stdout
%41 = call i32 @fwrite(i8* %4, i32 %39, i32 1, i32 %40)
%42 = load i32, i32* %2
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %9
%45 = call i32 @strlen(i8* %4)
%46 = load i32, i32* @stdout
%47 = call i32 @fwrite(i8* %4, i32 %45, i32 1, i32 %46)
%48 = call i64 (...) @getpid()
%49 = trunc i64 %48 to i32
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %49)
%51 = call i32 @strlen(i8* %4)
%52 = load i32, i32* @stdout
%53 = call i32 @fwrite(i8* %4, i32 %51, i32 1, i32 %52)
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0), i32 %7)
%55 = call i32 @strlen(i8* %4)
%56 = load i32, i32* @stdout
%57 = call i32 @fwrite(i8* %4, i32 %55, i32 1, i32 %56)
%58 = call i32 @strlen(i8* %4)
%59 = load i32, i32* @stdout
%60 = call i32 @fwrite(i8* %4, i32 %58, i32 1, i32 %59)
%61 = call i32 @wait(i32* %3)
%62 = load i32, i32* %3
%63 = sdiv i32 %62, 256
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0), i32 %63)
%65 = call i32 @strlen(i8* %4)
%66 = load i32, i32* @stdout
%67 = call i32 @fwrite(i8* %4, i32 %65, i32 1, i32 %66)
%68 = call i32 @strlen(i8* %4)
%69 = load i32, i32* @stdout
%70 = call i32 @fwrite(i8* %4, i32 %68, i32 1, i32 %69)
%71 = call i32 @exit(i32 0)
unreachable
72: ; preds = %0
%73 = load i32, i32* @stderr
%74 = tail call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
%75 = tail call i32 @exit(i32 0)
unreachable
}