#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 int /*<<< orphan*/ pid_t;

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int PROT_READ;
int PROT_WRITE;
int S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ close(int);
int errno;
scalar_t__ execl(char *, char *, char *, char *, char *, char *,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ftruncate(int, int);
scalar_t__ malloc(int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ random_gen(char *, int);
int shm_open(char *, int, int);
int shm_unlink(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unsetenv(char *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int sc_close(int fd) {
  pid_t child_pid;
  char *shared_memory_key = NULL;
  void *shared_memory_ptr = NULL;
  int shared_memory_fd = -1;
  int op_ret = -1;
  int child_ret = -1;
  int func_ret = -1;
  int memory_length = 0;
  shared_memory_key = (char *)malloc(sizeof(char) * 20);
  random_gen(shared_memory_key, 20);
  shared_memory_fd = shm_open(shared_memory_key, O_CREAT | O_RDWR,
                              S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
  if (shared_memory_fd != -1) {
    ;
  } else {
    fprintf(stderr, "creating the shared memory failed\n");
    fprintf(stderr, "the error code is %d\n", errno);
    goto sc_close_exit;
  }
  memory_length = sizeof(int);
  op_ret = ftruncate(shared_memory_fd, memory_length);
  if (!op_ret) {
    ;
  } else {
    fprintf(stderr, "the error code is %d\n", errno);
    goto sc_close_clean;
  }
  shared_memory_ptr = mmap(NULL, memory_length, PROT_WRITE | PROT_READ,
                           MAP_SHARED, shared_memory_fd, 0);
  if (shared_memory_ptr != MAP_FAILED) {
    *((int *)shared_memory_ptr) = fd;
  }
  if (!(child_pid = fork())) {
    unsetenv("LD_PRELOAD");
    if (execl("./sm-proxy.py", "./sm-proxy.py", "-k", shared_memory_key, "-t",
              "4", NULL) < 0) {
      fprintf(stderr, "error\n");
      fprintf(stderr, "error is %d\n", errno);
    }
  } else {
    waitpid(child_pid, &child_ret, 0);
    if (WIFEXITED(child_ret)) {
      func_ret = *(int *)shared_memory_ptr;
    } else {
      errno = 3;
    }
  }
sc_close_clean:
  op_ret = shm_unlink(shared_memory_key);
  if (!op_ret) {
    close(shared_memory_fd);
  } else {
    fprintf(stderr, "unlinking the shared memory not succeed\n");
    fprintf(stderr, "the error code is %d\n", errno);
    func_ret = op_ret;
  }
sc_close_exit:
  if (func_ret == -1) {
    errno = 5;
  }
  return func_ret;
}


x86 assembly (clang, -O0):
<sc_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   10c0 <random_gen@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
mov    0x2d92(%rip),%rax
or     (%rax),%esi
mov    0x2d51(%rip),%rax
mov    (%rax),%edx
mov    0x2d78(%rip),%rax
or     (%rax),%edx
mov    0x2d4f(%rip),%rax
or     (%rax),%edx
mov    0x2d1e(%rip),%rax
or     (%rax),%edx
call   10b0 <shm_open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     127b <sc_close+0xab>
jmp    12b7 <sc_close+0xe7>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1490 <sc_close+0x2c0>
movl   $0x4,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1040 <ftruncate@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    12db <sc_close+0x10b>
jmp    1300 <sc_close+0x130>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    0x2cc5(%rip),%rax
mov    (%rax),%edx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    142b <sc_close+0x25b>
mov    -0x2c(%rbp),%esi
mov    0x2c96(%rip),%rax
mov    (%rax),%edx
mov    0x2cdd(%rip),%rax
or     (%rax),%edx
mov    0x2cc4(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c53(%rip),%rcx
cmp    (%rcx),%rax
je     134f <sc_close+0x17f>
mov    -0x4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    13e6 <sc_close+0x216>
lea    0xcd0(%rip),%rdi
call   1090 <unsetenv@plt>
mov    -0x10(%rbp),%rcx
lea    0xccb(%rip),%rsi
lea    0xcd2(%rip),%rdx
lea    0xcce(%rip),%r8
lea    0xcca(%rip),%r9
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   10d0 <execl@plt>
cmp    $0x0,%rax
jge    13e1 <sc_close+0x211>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
mov    0x2bdf(%rip),%rax
mov    (%rax),%edx
lea    0xc87(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1426 <sc_close+0x256>
mov    -0x8(%rbp),%edi
lea    -0x24(%rbp),%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
mov    -0x24(%rbp),%edi
call   10a0 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1414 <sc_close+0x244>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    1421 <sc_close+0x251>
mov    0x2b95(%rip),%rax
movl   $0x3,(%rax)
jmp    1426 <sc_close+0x256>
jmp    142b <sc_close+0x25b>
mov    -0x10(%rbp),%rdi
call   10e0 <shm_unlink@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    144e <sc_close+0x27e>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
jmp    148b <sc_close+0x2bb>
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
mov    0x2b3b(%rip),%rax
mov    (%rax),%edx
lea    0xba5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1490 <sc_close+0x2c0>
cmpl   $0xffffffff,-0x28(%rbp)
jne    14a7 <sc_close+0x2d7>
mov    0x2b0f(%rip),%rax
movl   $0x5,(%rax)
mov    -0x28(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_close>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
movl   $0xffffffff,0x14(%rsp)
ff
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x14,%esi
call   10c0 <random_gen@plt>
mov    0x2df2(%rip),%rax
mov    0x2dc3(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d80(%rip),%rax
mov    0x2da9(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d7e(%rip),%rax
or     (%rax),%edx
mov    0x2d4d(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
call   10b0 <shm_open@plt>
cmp    $0xffffffff,%eax
je     12cf <sc_close+0xff>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x4,%esi
call   1040 <ftruncate@plt>
test   %eax,%eax
je     131e <sc_close+0x14e>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%edx
lea    0xdad(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   10e0 <shm_unlink@plt>
test   %eax,%eax
je     1391 <sc_close+0x1c1>
mov    %eax,%ebx
mov    0x2d1d(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
lea    0xd64(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%ebp
cmp    $0xffffffff,%ebp
jne    1311 <sc_close+0x141>
jmp    12ff <sc_close+0x12f>
mov    0x2ce2(%rip),%rbx
mov    (%rbx),%edi
lea    0xd21(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
lea    0xd2b(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2caa(%rip),%rax
movl   $0x5,(%rax)
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c7b(%rip),%rax
mov    0x2cc4(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ca9(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbp
mov    0x2c3b(%rip),%rax
cmp    (%rax),%rbp
je     135e <sc_close+0x18e>
mov    %r14d,0x0(%rbp)
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     13a7 <sc_close+0x1d7>
lea    0x14(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1080 <waitpid@plt>
mov    0x14(%rsp),%edi
call   10a0 <WIFEXITED@plt>
test   %rax,%rax
je     1427 <sc_close+0x257>
mov    0x0(%rbp),%ebp
jmp    1282 <sc_close+0xb2>
mov    %r15d,%edi
call   1050 <close@plt>
cmp    $0xffffffff,%ebp
jne    1311 <sc_close+0x141>
jmp    12ff <sc_close+0x12f>
lea    0xc8b(%rip),%rdi
call   1090 <unsetenv@plt>
movq   $0x0,(%rsp)
lea    0xc82(%rip),%rdi
lea    0xc89(%rip),%rdx
lea    0xc85(%rip),%r8
lea    0xc81(%rip),%r9
mov    %rdi,%rsi
mov    %rbx,%rcx
call   10d0 <execl@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jns    1282 <sc_close+0xb2>
mov    0x2bc1(%rip),%r14
mov    (%r14),%edi
lea    0xc59(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
mov    0x2b9e(%rip),%rax
mov    (%rax),%edx
lea    0xc46(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1282 <sc_close+0xb2>
mov    0x2b82(%rip),%rax
movl   $0x3,(%rax)
jmp    127d <sc_close+0xad>

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"creating the shared memory failed\0A\00"
@.str.1 = [22 x i8] c"the error code is %d\0A\00"
@errno = global i32 0
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [11 x i8] c"LD_PRELOAD\00"
@.str.3 = [14 x i8] c"./sm-proxy.py\00"
@.str.4 = [3 x i8] c"-k\00"
@.str.5 = [3 x i8] c"-t\00"
@.str.6 = [2 x i8] c"4\00"
@.str.7 = [7 x i8] c"error\0A\00"
@.str.8 = [13 x i8] c"error is %d\0A\00"
@.str.9 = [41 x i8] c"unlinking the shared memory not succeed\0A\00"
define i32 @sc_close(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %2
store i8* null, i8** %4
store i8* null, i8** %5
store i32 -1, i32* %6
store i32 -1, i32* %7
store i32 -1, i32* %8
store i32 -1, i32* %9
store i32 0, i32* %10
%11 = call i64 @malloc(i32 20)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @random_gen(i8* %13, i32 20)
%15 = load i8*, i8** %4
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_RDWR
%18 = or i32 %16, %17
%19 = load i32, i32* @S_IRUSR
%20 = load i32, i32* @S_IWUSR
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IROTH
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IWOTH
%25 = or i32 %23, %24
%26 = call i32 @shm_open(i8* %15, i32 %18, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %1
br label %36
30: ; preds = %1
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %106
36: ; preds = %29
store i32 4, i32* %10
%37 = load i32, i32* %6
%38 = load i32, i32* %10
%39 = call i32 @ftruncate(i32 %37, i32 %38)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %36
br label %47
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %90
47: ; preds = %42
%48 = load i32, i32* %10
%49 = load i32, i32* @PROT_WRITE
%50 = load i32, i32* @PROT_READ
%51 = or i32 %49, %50
%52 = load i32, i32* @MAP_SHARED
%53 = load i32, i32* %6
%54 = call i8* @mmap(i32* null, i32 %48, i32 %51, i32 %52, i32 %53, i32 0)
store i8* %54, i8** %5
%55 = load i8*, i8** %5
%56 = load i8*, i8** @MAP_FAILED
%57 = icmp ne i8* %55, %56
br i1 %57, label %58, label %62
58: ; preds = %47
%59 = load i32, i32* %2
%60 = load i8*, i8** %5
%61 = bitcast i8* %60 to i32*
store i32 %59, i32* %61
br label %62
62: ; preds = %58, %47
%63 = call i32 (...) @fork()
store i32 %63, i32* %3
%64 = icmp ne i32 %63, 0
br i1 %64, label %77, label %65
65: ; preds = %62
%66 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%67 = load i8*, i8** %4
%68 = call i64 @execl(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32* null)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %65
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %70, %65
br label %89
77: ; preds = %62
%78 = load i32, i32* %3
%79 = call i32 @waitpid(i32 %78, i32* %8, i32 0)
%80 = load i32, i32* %8
%81 = call i64 @WIFEXITED(i32 %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %87
83: ; preds = %77
%84 = load i8*, i8** %5
%85 = bitcast i8* %84 to i32*
%86 = load i32, i32* %85
store i32 %86, i32* %9
br label %88
87: ; preds = %77
store i32 3, i32* @errno
br label %88
88: ; preds = %87, %83
br label %89
89: ; preds = %88, %76
br label %90
90: ; preds = %89, %43
%91 = load i8*, i8** %4
%92 = call i32 @shm_unlink(i8* %91)
store i32 %92, i32* %7
%93 = load i32, i32* %7
%94 = icmp ne i32 %93, 0
br i1 %94, label %98, label %95
95: ; preds = %90
%96 = load i32, i32* %6
%97 = call i32 @close(i32 %96)
br label %105
98: ; preds = %90
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
%101 = load i32, i32* @stderr
%102 = load i32, i32* @errno
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %102)
%104 = load i32, i32* %7
store i32 %104, i32* %9
br label %105
105: ; preds = %98, %95
br label %106
106: ; preds = %105, %30
%107 = load i32, i32* %9
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %110
109: ; preds = %106
store i32 5, i32* @errno
br label %110
110: ; preds = %109, %106
%111 = load i32, i32* %9
ret i32 %111
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@stderr = global i32 0
@.str = [35 x i8] c"creating the shared memory failed\0A\00"
@.str.1 = [22 x i8] c"the error code is %d\0A\00"
@errno = global i32 0
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [11 x i8] c"LD_PRELOAD\00"
@.str.3 = [14 x i8] c"./sm-proxy.py\00"
@.str.4 = [3 x i8] c"-k\00"
@.str.5 = [3 x i8] c"-t\00"
@.str.6 = [2 x i8] c"4\00"
@.str.7 = [7 x i8] c"error\0A\00"
@.str.8 = [13 x i8] c"error is %d\0A\00"
@.str.9 = [41 x i8] c"unlinking the shared memory not succeed\0A\00"
define i32 @sc_close(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%4 = tail call i64 @malloc(i32 20)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @random_gen(i8* %5, i32 20)
%7 = load i32, i32* @O_CREAT
%8 = load i32, i32* @O_RDWR
%9 = or i32 %8, %7
%10 = load i32, i32* @S_IRUSR
%11 = load i32, i32* @S_IWUSR
%12 = or i32 %11, %10
%13 = load i32, i32* @S_IROTH
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IWOTH
%16 = or i32 %14, %15
%17 = tail call i32 @shm_open(i8* %5, i32 %9, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %25
19: ; preds = %1
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %79
25: ; preds = %1
%26 = tail call i32 @ftruncate(i32 %17, i32 4)
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = load i32, i32* @errno
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %64
32: ; preds = %25
%33 = load i32, i32* @PROT_WRITE
%34 = load i32, i32* @PROT_READ
%35 = or i32 %34, %33
%36 = load i32, i32* @MAP_SHARED
%37 = tail call i8* @mmap(i32* null, i32 4, i32 %35, i32 %36, i32 %17, i32 0)
%38 = load i8*, i8** @MAP_FAILED
%39 = icmp eq i8* %37, %38
br i1 %39, label %42, label %40
40: ; preds = %32
%41 = bitcast i8* %37 to i32*
store i32 %0, i32* %41
br label %42
42: ; preds = %40, %32
%43 = tail call i32 (...) @fork()
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = tail call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%47 = tail call i64 @execl(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32* null)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %64
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %53)
br label %64
55: ; preds = %42
%56 = call i32 @waitpid(i32 %43, i32* %2, i32 0)
%57 = load i32, i32* %2
%58 = call i64 @WIFEXITED(i32 %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %55
%61 = bitcast i8* %37 to i32*
%62 = load i32, i32* %61
br label %64
63: ; preds = %55
store i32 3, i32* @errno
br label %64
64: ; preds = %49, %45, %63, %60, %28
%65 = phi i32 [ -1, %28 ], [ %62, %60 ], [ -1, %63 ], [ -1, %49 ], [ -1, %45 ]
%66 = call i32 @shm_unlink(i8* %5)
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @close(i32 %17)
br label %76
70: ; preds = %64
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %68, %70
%77 = phi i32 [ %66, %70 ], [ %65, %68 ]
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %80
79: ; preds = %19, %76
store i32 5, i32* @errno
br label %80
80: ; preds = %79, %76
%81 = phi i32 [ -1, %79 ], [ %77, %76 ]
ret i32 %81
}