#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__ MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ PROT_READ;
int errno;
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ ftruncate(int, int);
int getpid();
scalar_t__ mmap(int /*<<< orphan*/, int, int /*<<< orphan*/, int /*<<< orphan*/,
                int, int /*<<< orphan*/);
scalar_t__ munmap(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int shm_open(char *, int, int);
scalar_t__ shm_unlink(char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ wait(int *);
scalar_t__ write(int, char *, int);
int main() {
  pid_t childid;
  int childec;
  int smd;
  char buffer[1024];
  smd = shm_open("/yummysaahare", O_CREAT | O_RDWR, 0644);
  if (!(0 <= smd))
    fprintf(stderr, "Error %s. Error : %s \n", "creating SMO", strerror(errno));
  ;
  if (!(0 <= ftruncate(smd, 1024)))
    fprintf(stderr, "Error %s. Error : %s \n", "setting SMO size",
            strerror(errno));
  ;
  childid = fork();
  if (childid > 0) {
    printf("I'm parent. pid : %d\n", getpid());
    if (!(MAP_FAILED != mmap(0, 1024, PROT_READ, MAP_SHARED, smd, 0)))
      fprintf(stderr, "Error %s. Error : %s \n",
              "mapping SMO to process memory", strerror(errno));
    ;
    if (!(0 <= read(smd, buffer, 1024)))
      fprintf(stderr, "Error %s. Error : %s \n", "reading SMO",
              strerror(errno));
    ;
    printf("Data received : %s \n", buffer);
    if (!(0 <= munmap(0, 1024)))
      fprintf(stderr, "Error %s. Error : %s \n",
              "unmapping SMO from local memory", strerror(errno));
    ;
    if (!(0 <= shm_unlink("/yummysaahare")))
      fprintf(stderr, "Error %s. Error : %s \n", "unlinking SMO",
              strerror(errno));
    ;
    wait(&childec);
    printf("Waited for child, exit code : %d\n", childec);
  } else if (childid == 0) {
    printf("I'm child. pid : %d\n", getpid());
    if (!(MAP_FAILED != mmap(0, 1024, PROT_READ, MAP_SHARED, smd, 0)))
      fprintf(stderr, "Error %s. Error : %s \n",
              "mapping SMO to process memory", strerror(errno));
    ;
    if (!(0 <= munmap(0, 1024)))
      fprintf(stderr, "Error %s. Error : %s \n",
              "unmapping SMO from local memory", strerror(errno));
    ;
    if (!(0 <= write(smd, "YOLO!", sizeof("YOLO!"))))
      fprintf(stderr, "Error %s. Error : %s \n", "writing SMO",
              strerror(errno));
    ;
  } else {
    printf("Failed to fork. Error code : %d \n", errno);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    0x2dde(%rip),%rax
or     (%rax),%esi
lea    0xe05(%rip),%rdi
mov    $0x1a4,%edx
call   10b0 <shm_open@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jle    124c <main+0x7c>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x424(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x424(%rbp),%edi
mov    %rax,%rcx
lea    0xdce(%rip),%rsi
lea    0xdde(%rip),%rdx
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%edi
mov    $0x400,%esi
call   1070 <ftruncate@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    12a0 <main+0xd0>
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x428(%rbp),%edi
mov    %rax,%rcx
lea    0xd7a(%rip),%rsi
lea    0xd97(%rip),%rdx
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    1485 <main+0x2b5>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x430(%rbp)
mov    0x2d0b(%rip),%rax
mov    (%rax),%edx
mov    0x2cf2(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x400,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,%rcx
mov    -0x430(%rbp),%rax
cmp    %rcx,%rax
jne    1350 <main+0x180>
mov    0x2ca2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x434(%rbp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x434(%rbp),%edi
mov    %rax,%rcx
lea    0xcca(%rip),%rsi
lea    0xd0e(%rip),%rdx
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    13ab <main+0x1db>
mov    0x2c47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x438(%rbp)
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x438(%rbp),%edi
mov    %rax,%rcx
lea    0xc6f(%rip),%rsi
lea    0xcd1(%rip),%rdx
call   1090 <fprintf@plt>
lea    -0x420(%rbp),%rsi
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x400,%esi
call   10a0 <munmap@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1413 <main+0x243>
mov    0x2bdf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x43c(%rbp)
mov    0x2bc8(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x43c(%rbp),%edi
mov    %rax,%rcx
lea    0xc07(%rip),%rsi
lea    0xc8a(%rip),%rdx
call   1090 <fprintf@plt>
lea    0xbe6(%rip),%rdi
call   10d0 <shm_unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1466 <main+0x296>
mov    0x2b8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x440(%rbp)
mov    0x2b75(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x440(%rbp),%edi
mov    %rax,%rcx
lea    0xbb4(%rip),%rsi
lea    0xc57(%rip),%rdx
call   1090 <fprintf@plt>
lea    -0x14(%rbp),%rdi
call   10e0 <wait@plt>
mov    -0x14(%rbp),%esi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15f9 <main+0x429>
cmpq   $0x0,-0x10(%rbp)
jne    15dd <main+0x40d>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b02(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x448(%rbp)
mov    0x2b31(%rip),%rax
mov    (%rax),%edx
mov    0x2b18(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x400,%esi
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,%rcx
mov    -0x448(%rbp),%rax
cmp    %rcx,%rax
jne    152a <main+0x35a>
mov    0x2ac8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44c(%rbp)
mov    0x2ab1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x44c(%rbp),%edi
mov    %rax,%rcx
lea    0xaf0(%rip),%rsi
lea    0xb34(%rip),%rdx
call   1090 <fprintf@plt>
xor    %edi,%edi
mov    $0x400,%esi
call   10a0 <munmap@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    157d <main+0x3ad>
mov    0x2a75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x450(%rbp)
mov    0x2a5e(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x450(%rbp),%edi
mov    %rax,%rcx
lea    0xa9d(%rip),%rsi
lea    0xb20(%rip),%rdx
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%edi
lea    0xb76(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    15d8 <main+0x408>
mov    0x2a1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x454(%rbp),%edi
mov    %rax,%rcx
lea    0xa42(%rip),%rsi
lea    0xb30(%rip),%rdx
call   1090 <fprintf@plt>
jmp    15f4 <main+0x424>
mov    0x29d4(%rip),%rax
mov    (%rax),%esi
lea    0xb22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15f9 <main+0x429>
xor    %eax,%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x418,%rsp
mov    0x2e18(%rip),%rax
mov    0x2de9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe0e(%rip),%rdi
mov    $0x1a4,%edx
call   10b0 <shm_open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1231 <main+0x61>
mov    0x2db7(%rip),%rax
mov    (%rax),%ebp
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xdee(%rip),%rsi
lea    0xdfe(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
mov    %ebx,%edi
mov    $0x400,%esi
call   1070 <ftruncate@plt>
test   %rax,%rax
jns    1271 <main+0xa1>
mov    0x2d77(%rip),%rax
mov    (%rax),%ebp
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xdae(%rip),%rsi
lea    0xdcb(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
jle    13e9 <main+0x219>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%rbp
mov    0x2d47(%rip),%rax
mov    (%rax),%edx
mov    0x2d2e(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x400,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    %rax,%rbp
jne    12fa <main+0x12a>
mov    0x2cee(%rip),%rax
mov    (%rax),%ebp
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd25(%rip),%rsi
lea    0xd69(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x400,%edx
call   1080 <read@plt>
test   %rax,%rax
jns    133f <main+0x16f>
mov    0x2ca9(%rip),%rax
mov    (%rax),%ebx
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xce0(%rip),%rsi
lea    0xd42(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    0xd3d(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x400,%esi
call   10a0 <munmap@plt>
test   %rax,%rax
jns    1392 <main+0x1c2>
mov    0x2c56(%rip),%rax
mov    (%rax),%ebx
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc8d(%rip),%rsi
lea    0xd10(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    0xc67(%rip),%rdi
call   10d0 <shm_unlink@plt>
test   %rax,%rax
jns    13d2 <main+0x202>
mov    0x2c16(%rip),%rax
mov    (%rax),%ebx
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc4d(%rip),%rsi
lea    0xcf0(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    0xc(%rsp),%rdi
call   10e0 <wait@plt>
mov    0xc(%rsp),%esi
lea    0xcdf(%rip),%rdi
jmp    13fb <main+0x22b>
je     140e <main+0x23e>
mov    0x2bc6(%rip),%rax
mov    (%rax),%esi
lea    0xd14(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xccc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2b84(%rip),%rax
mov    (%rax),%rbp
mov    0x2bba(%rip),%rax
mov    (%rax),%edx
mov    0x2ba1(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x400,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
cmp    %rax,%rbp
jne    1487 <main+0x2b7>
mov    0x2b61(%rip),%rax
mov    (%rax),%ebp
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb98(%rip),%rsi
lea    0xbdc(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
xor    %edi,%edi
mov    $0x400,%esi
call   10a0 <munmap@plt>
test   %rax,%rax
jns    14c7 <main+0x2f7>
mov    0x2b21(%rip),%rax
mov    (%rax),%ebp
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb58(%rip),%rsi
lea    0xbdb(%rip),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
lea    0xc2f(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <write@plt>
test   %rax,%rax
jns    1402 <main+0x232>
mov    0x2ad6(%rip),%rax
mov    (%rax),%ebx
mov    0x2ac5(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb0d(%rip),%rsi
lea    0xbfb(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1090 <fprintf@plt>
jmp    1402 <main+0x232>

LLVM IR (-O0):
@.str = [14 x i8] c"/yummysaahare\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error %s. Error : %s \0A\00"
@.str.2 = [13 x i8] c"creating SMO\00"
@errno = global i32 0
@.str.3 = [17 x i8] c"setting SMO size\00"
@.str.4 = [22 x i8] c"I'm parent. pid : %d\0A\00"
@MAP_FAILED = global i64 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.5 = [30 x i8] c"mapping SMO to process memory\00"
@.str.6 = [12 x i8] c"reading SMO\00"
@.str.7 = [21 x i8] c"Data received : %s \0A\00"
@.str.8 = [32 x i8] c"unmapping SMO from local memory\00"
@.str.9 = [14 x i8] c"unlinking SMO\00"
@.str.10 = [34 x i8] c"Waited for child, exit code : %d\0A\00"
@.str.11 = [21 x i8] c"I'm child. pid : %d\0A\00"
@.str.12 = [6 x i8] c"YOLO!\00"
@.str.13 = [12 x i8] c"writing SMO\00"
@.str.14 = [34 x i8] c"Failed to fork. Error code : %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
store i32 0, i32* %1
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_RDWR
%8 = or i32 %6, %7
%9 = call i32 @shm_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %8, i32 420)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp sle i32 0, %10
br i1 %11, label %17, label %12
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = call i8* @strerror(i32 %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %12, %0
%18 = load i32, i32* %4
%19 = call i64 @ftruncate(i32 %18, i32 1024)
%20 = icmp sle i64 0, %19
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %17
%27 = call i64 (...) @fork()
store i64 %27, i64* %2
%28 = load i64, i64* %2
%29 = icmp sgt i64 %28, 0
br i1 %29, label %30, label %76
30: ; preds = %26
%31 = call i32 (...) @getpid()
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i64, i64* @MAP_FAILED
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @MAP_SHARED
%36 = load i32, i32* %4
%37 = call i64 @mmap(i32 0, i32 1024, i32 %34, i32 %35, i32 %36, i32 0)
%38 = icmp ne i64 %33, %37
br i1 %38, label %44, label %39
39: ; preds = %30
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %39, %30
%45 = load i32, i32* %4
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%47 = call i64 @read(i32 %45, i8* %46, i32 1024)
%48 = icmp sle i64 0, %47
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %49, %44
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = call i64 @munmap(i32 0, i32 1024)
%58 = icmp sle i64 0, %57
br i1 %58, label %64, label %59
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %59, %54
%65 = call i64 @shm_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%66 = icmp sle i64 0, %65
br i1 %66, label %72, label %67
67: ; preds = %64
%68 = load i32, i32* @stderr
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %67, %64
%73 = call i32 @wait(i32* %3)
%74 = load i32, i32* %3
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %74)
br label %115
76: ; preds = %26
%77 = load i64, i64* %2
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %111
79: ; preds = %76
%80 = call i32 (...) @getpid()
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %80)
%82 = load i64, i64* @MAP_FAILED
%83 = load i32, i32* @PROT_READ
%84 = load i32, i32* @MAP_SHARED
%85 = load i32, i32* %4
%86 = call i64 @mmap(i32 0, i32 1024, i32 %83, i32 %84, i32 %85, i32 0)
%87 = icmp ne i64 %82, %86
br i1 %87, label %93, label %88
88: ; preds = %79
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = call i8* @strerror(i32 %90)
%92 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %88, %79
%94 = call i64 @munmap(i32 0, i32 1024)
%95 = icmp sle i64 0, %94
br i1 %95, label %101, label %96
96: ; preds = %93
%97 = load i32, i32* @stderr
%98 = load i32, i32* @errno
%99 = call i8* @strerror(i32 %98)
%100 = call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %96, %93
%102 = load i32, i32* %4
%103 = call i64 @write(i32 %102, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 6)
%104 = icmp sle i64 0, %103
br i1 %104, label %110, label %105
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = load i32, i32* @errno
%108 = call i8* @strerror(i32 %107)
%109 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* %108)
br label %110
110: ; preds = %105, %101
br label %114
111: ; preds = %76
%112 = load i32, i32* @errno
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %111, %110
br label %115
115: ; preds = %114, %72
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"/yummysaahare\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error %s. Error : %s \0A\00"
@.str.2 = [13 x i8] c"creating SMO\00"
@errno = global i32 0
@.str.3 = [17 x i8] c"setting SMO size\00"
@.str.4 = [22 x i8] c"I'm parent. pid : %d\0A\00"
@MAP_FAILED = global i64 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@.str.5 = [30 x i8] c"mapping SMO to process memory\00"
@.str.6 = [12 x i8] c"reading SMO\00"
@.str.7 = [21 x i8] c"Data received : %s \0A\00"
@.str.8 = [32 x i8] c"unmapping SMO from local memory\00"
@.str.9 = [14 x i8] c"unlinking SMO\00"
@.str.10 = [34 x i8] c"Waited for child, exit code : %d\0A\00"
@.str.11 = [21 x i8] c"I'm child. pid : %d\0A\00"
@.str.12 = [6 x i8] c"YOLO!\00"
@.str.13 = [12 x i8] c"writing SMO\00"
@.str.14 = [34 x i8] c"Failed to fork. Error code : %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_RDWR
%7 = or i32 %6, %5
%8 = tail call i32 @shm_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7, i32 420)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %15, label %10
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %0
%16 = tail call i64 @ftruncate(i32 %8, i32 1024)
%17 = icmp sgt i64 %16, -1
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %18, %15
%24 = tail call i64 (...) @fork()
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %68
26: ; preds = %23
%27 = tail call i32 (...) @getpid()
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i64, i64* @MAP_FAILED
%30 = load i32, i32* @PROT_READ
%31 = load i32, i32* @MAP_SHARED
%32 = tail call i64 @mmap(i32 0, i32 1024, i32 %30, i32 %31, i32 %8, i32 0)
%33 = icmp eq i64 %29, %32
br i1 %33, label %34, label %39
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = load i32, i32* @errno
%37 = tail call i8* @strerror(i32 %36)
%38 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %26
%40 = call i64 @read(i32 %8, i8* %4, i32 1024)
%41 = icmp sgt i64 %40, -1
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %42, %39
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%49 = call i64 @munmap(i32 0, i32 1024)
%50 = icmp sgt i64 %49, -1
br i1 %50, label %56, label %51
51: ; preds = %47
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %51, %47
%57 = call i64 @shm_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%58 = icmp sgt i64 %57, -1
br i1 %58, label %64, label %59
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %59, %56
%65 = call i32 @wait(i32* %1)
%66 = load i32, i32* %1
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %66)
br label %102
68: ; preds = %23
%69 = icmp eq i64 %24, 0
br i1 %69, label %70, label %99
70: ; preds = %68
%71 = tail call i32 (...) @getpid()
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i32 %71)
%73 = load i64, i64* @MAP_FAILED
%74 = load i32, i32* @PROT_READ
%75 = load i32, i32* @MAP_SHARED
%76 = tail call i64 @mmap(i32 0, i32 1024, i32 %74, i32 %75, i32 %8, i32 0)
%77 = icmp eq i64 %73, %76
br i1 %77, label %78, label %83
78: ; preds = %70
%79 = load i32, i32* @stderr
%80 = load i32, i32* @errno
%81 = tail call i8* @strerror(i32 %80)
%82 = tail call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %78, %70
%84 = tail call i64 @munmap(i32 0, i32 1024)
%85 = icmp sgt i64 %84, -1
br i1 %85, label %91, label %86
86: ; preds = %83
%87 = load i32, i32* @stderr
%88 = load i32, i32* @errno
%89 = tail call i8* @strerror(i32 %88)
%90 = tail call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %89)
br label %91
91: ; preds = %86, %83
%92 = tail call i64 @write(i32 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 6)
%93 = icmp sgt i64 %92, -1
br i1 %93, label %102, label %94
94: ; preds = %91
%95 = load i32, i32* @stderr
%96 = load i32, i32* @errno
%97 = tail call i8* @strerror(i32 %96)
%98 = tail call i32 @fprintf(i32 %95, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i8* %97)
br label %102
99: ; preds = %68
%100 = load i32, i32* @errno
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i32 %100)
br label %102
102: ; preds = %99, %94, %91, %64
ret i32 0
}