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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
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;
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);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ random_gen(char *, int);
int shm_open(char *, int, int);
int shm_unlink(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  pid_t my_pid;
  char *my_string;
  int size;
  FILE *fp = NULL;
  int sfd = -1;
  int socket_args[3] = {2, 1, 0};
  int ret = -1;
  void *shared_memory_ptr = NULL;
  int *temp_ptr = NULL;
  my_string = (char *)malloc(sizeof(char) * 20);
  random_gen(my_string, 20);
  printf("my random string is %s\n", my_string);
  sfd = shm_open(my_string, O_CREAT | O_RDWR,
                 S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
  if (sfd != -1) {
    fprintf(stderr, "the shared memory descriptor is %d\n", sfd);
    fprintf(stderr, "creating the shared memory succeed\n");
  } else {
    fprintf(stderr, "the error code is %d\n", errno);
    goto error_exit;
  }
  ret = ftruncate(sfd, sizeof(int) * 3);
  if (!ret) {
    fprintf(stderr, "truncating the shared memory succeed\n");
  } else {
    fprintf(stderr, "the error code is %d\n", errno);
    goto error_exit;
  }
  shared_memory_ptr =
      mmap(NULL, sizeof(int) * 3, PROT_WRITE | PROT_READ, MAP_SHARED, sfd, 0);
  if (shared_memory_ptr != MAP_FAILED) {
    *((int *)shared_memory_ptr) = 2;
    *((int *)shared_memory_ptr + 1) = 1;
    *((int *)shared_memory_ptr + 2) = 0;
  }
  getchar();
  my_pid = fork();
  if (!my_pid) {
    if (execl("./sm-proxy.py", "./sm-proxy.py", "-k", my_string, "-t", "0",
              NULL) < 0) {
      printf("error\n");
      printf("error is %d\n", errno);
    }
  } else {
    sleep(2);
    waitpid(my_pid, NULL, 0);
  }
  fprintf(stderr, "the ret value from the python script is %d\n",
          *(int *)shared_memory_ptr);
  ret = shm_unlink(my_string);
  if (!ret) {
    fprintf(stderr, "unlinking the shared memory succeed\n");
  } else {
    fprintf(stderr, "the error code is %d\n", errno);
    goto error_exit;
  }
succ_exit:
  return EXIT_SUCCESS;
error_exit:
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
mov    0xe04(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe02(%rip),%eax
mov    %eax,-0x38(%rbp)
movl   $0xffffffff,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    $0x14,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   10b0 <random_gen@plt>
mov    -0x20(%rbp),%rsi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
mov    0x2d6e(%rip),%rax
or     (%rax),%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%edx
mov    0x2d54(%rip),%rax
or     (%rax),%edx
mov    0x2d2b(%rip),%rax
or     (%rax),%edx
mov    0x2cea(%rip),%rax
or     (%rax),%edx
call   10a0 <shm_open@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
je     12d0 <main+0x100>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12f5 <main+0x125>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    0x2cd0(%rip),%rax
mov    (%rax),%edx
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    14db <main+0x30b>
mov    -0x34(%rbp),%edi
mov    $0xc,%esi
call   1050 <ftruncate@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    132b <main+0x15b>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1350 <main+0x180>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
mov    0x2c75(%rip),%rax
mov    (%rax),%edx
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    14db <main+0x30b>
mov    0x2c41(%rip),%rax
mov    (%rax),%edx
mov    0x2c90(%rip),%rax
or     (%rax),%edx
mov    0x2c77(%rip),%rax
mov    (%rax),%ecx
mov    -0x34(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0xc,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    0x2bf1(%rip),%rcx
cmp    (%rcx),%rax
je     13b8 <main+0x1e8>
mov    -0x50(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x50(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x50(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1439 <main+0x269>
mov    -0x20(%rbp),%rcx
lea    0xcca(%rip),%rsi
lea    0xcd1(%rip),%rdx
lea    0xccd(%rip),%r8
lea    0xcc9(%rip),%r9
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   10c0 <execl@plt>
cmp    $0x0,%rax
jge    1434 <main+0x264>
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b8c(%rip),%rax
mov    (%rax),%esi
lea    0xc98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1451 <main+0x281>
mov    $0x2,%edi
call   10e0 <sleep@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <waitpid@plt>
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   10d0 <shm_unlink@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    14a0 <main+0x2d0>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
lea    0xc6a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    14c5 <main+0x2f5>
mov    0x2b11(%rip),%rax
mov    (%rax),%edi
mov    0x2b00(%rip),%rax
mov    (%rax),%edx
lea    0xbb3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    14db <main+0x30b>
jmp    14ca <main+0x2fa>
mov    0x2ab7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14e7 <main+0x317>
mov    0x2abe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x14,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x14,%esi
call   10c0 <random_gen@plt>
lea    0xdf8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    0x2db0(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d65(%rip),%rax
mov    0x2d96(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d6b(%rip),%rax
or     (%rax),%edx
mov    0x2d2a(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
call   10b0 <shm_open@plt>
mov    0x2d61(%rip),%r15
mov    (%r15),%edi
cmp    $0xffffffff,%eax
je     13a1 <main+0x1c1>
mov    %eax,%ebp
lea    0xdac(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r15),%edi
lea    0xdbd(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %ebp,%edi
mov    $0xc,%esi
call   1060 <ftruncate@plt>
mov    (%r15),%edi
test   %eax,%eax
jne    13a1 <main+0x1c1>
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2ce6(%rip),%rax
mov    0x2d37(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d1c(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0xc,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r14
mov    0x2c9e(%rip),%rax
cmp    (%rax),%r14
je     12fc <main+0x11c>
movabs $0x100000002,%rax
mov    %rax,(%r14)
movl   $0x0,0x8(%r14)
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
je     1327 <main+0x147>
mov    %eax,%ebp
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
jmp    137e <main+0x19e>
movq   $0x0,(%rsp)
lea    0xd66(%rip),%rdi
lea    0xd6d(%rip),%rdx
lea    0xd69(%rip),%r8
lea    0xd65(%rip),%r9
mov    %rdi,%rsi
mov    %rbx,%rcx
call   10d0 <execl@plt>
test   %rax,%rax
jns    137e <main+0x19e>
lea    0xdae(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c42(%rip),%rax
mov    (%rax),%esi
lea    0xd3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%edi
mov    (%r14),%edx
lea    0xd34(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   10e0 <shm_unlink@plt>
mov    (%r15),%edi
test   %eax,%eax
je     13cc <main+0x1ec>
mov    0x2c08(%rip),%rax
mov    (%rax),%edx
lea    0xcaf(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2be1(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd18(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2ba7(%rip),%rax
jmp    13bf <main+0x1df>

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

LLVM IR (-O2):
@.str = [24 x i8] c"my random string is %s\0A\00"
@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.1 = [36 x i8] c"the shared memory descriptor is %d\0A\00"
@.str.2 = [36 x i8] c"creating the shared memory succeed\0A\00"
@.str.3 = [22 x i8] c"the error code is %d\0A\00"
@errno = global i32 0
@.str.4 = [38 x i8] c"truncating the shared memory succeed\0A\00"
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.5 = [14 x i8] c"./sm-proxy.py\00"
@.str.6 = [3 x i8] c"-k\00"
@.str.7 = [3 x i8] c"-t\00"
@.str.8 = [2 x i8] c"0\00"
@.str.10 = [13 x i8] c"error is %d\0A\00"
@.str.11 = [44 x i8] c"the ret value from the python script is %d\0A\00"
@.str.12 = [37 x i8] c"unlinking the shared memory succeed\0A\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@str = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 20)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @random_gen(i8* %4, i32 20)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %4)
%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* %4, i32 %9, i32 %16)
%18 = icmp eq i32 %17, -1
%19 = load i32, i32* @stderr
br i1 %18, label %27, label %20
20: ; preds = %2
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @ftruncate(i32 %17, i32 12)
%25 = icmp eq i32 %24, 0
%26 = load i32, i32* @stderr
br i1 %25, label %30, label %39
27: ; preds = %2
%28 = load i32, i32* @errno
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %75
30: ; preds = %20
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @PROT_WRITE
%33 = load i32, i32* @PROT_READ
%34 = or i32 %33, %32
%35 = load i32, i32* @MAP_SHARED
%36 = tail call i8* @mmap(i32* null, i32 12, i32 %34, i32 %35, i32 %17, i32 0)
%37 = load i8*, i8** @MAP_FAILED
%38 = icmp eq i8* %36, %37
br i1 %38, label %48, label %42
39: ; preds = %20
%40 = load i32, i32* @errno
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %75
42: ; preds = %30
%43 = bitcast i8* %36 to i32*
store i32 2, i32* %43
%44 = getelementptr inbounds i8, i8* %36, i64 4
%45 = bitcast i8* %44 to i32*
store i32 1, i32* %45
%46 = getelementptr inbounds i8, i8* %36, i64 8
%47 = bitcast i8* %46 to i32*
store i32 0, i32* %47
br label %48
48: ; preds = %42, %30
%49 = tail call i32 (...) @getchar()
%50 = tail call i32 (...) @fork()
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %48
%53 = tail call i64 @execl(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* null)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%57 = load i32, i32* @errno
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %57)
br label %62
59: ; preds = %48
%60 = tail call i32 @sleep(i32 2)
%61 = tail call i32 @waitpid(i32 %50, i32* null, i32 0)
br label %62
62: ; preds = %52, %55, %59
%63 = load i32, i32* @stderr
%64 = bitcast i8* %36 to i32*
%65 = load i32, i32* %64
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i32 %65)
%67 = tail call i32 @shm_unlink(i8* %4)
%68 = icmp eq i32 %67, 0
%69 = load i32, i32* @stderr
br i1 %68, label %70, label %72
70: ; preds = %62
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
br label %75
72: ; preds = %62
%73 = load i32, i32* @errno
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %27, %39, %72, %70
%76 = phi i32* [ @EXIT_SUCCESS, %70 ], [ @EXIT_FAILURE, %72 ], [ @EXIT_FAILURE, %39 ], [ @EXIT_FAILURE, %27 ]
%77 = load i32, i32* %76
ret i32 %77
}