#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 */
struct sembuf {
  int sem_op;
  scalar_t__ sem_num;
  scalar_t__ sem_flg;
};
typedef int /*<<< orphan*/ key_t;

/* Variables and functions */
scalar_t__ EEXIST;
int IPC_CREAT;
int IPC_EXCL;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ftok(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int semget(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ semop(int, struct sembuf *, int);
scalar_t__ shmat(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ shmdt(int *);
int shmget(int /*<<< orphan*/, int, int);
int main() {
  int *array;
  int shmid, semid;
  int new1 = 1;
  char pathname[] = "temp3";
  key_t key_shm, key_sem;
  struct sembuf mysem;
  if ((key_shm = ftok(pathname, 0)) < 0) {
    printf("Can\'t generate shared memory key\n");
    exit(-1);
  }
  if ((shmid = shmget(key_shm, 3 * sizeof(int), 0666 | IPC_CREAT | IPC_EXCL)) <
      0) {
    if (errno != EEXIST) {
      printf("Can\'t create shared memory\n");
      exit(-1);
    } else {
      if ((shmid = shmget(key_shm, 3 * sizeof(int), 0)) < 0) {
        printf("Can\'t find shared memory\n");
        exit(-1);
      }
      new1 = 0;
    }
  }
  if ((array = (int *)shmat(shmid, NULL, 0)) == (int *)(-1)) {
    printf("Can't attach shared memory\n");
    exit(-1);
  }
  if ((key_sem = ftok(pathname, 0)) < 0) {
    printf("Can\'t generate sem key\n");
    exit(-1);
  }
  if ((semid = semget(key_sem, 1, 0666 | IPC_CREAT)) < 0) {
    printf("Can\'t get semid\n");
    exit(-1);
  }
  mysem.sem_op = 0;
  mysem.sem_flg = 0;
  mysem.sem_num = 0;
  if (new1) {
    array[0] = 0;
    array[1] = 1;
    array[2] = 1;
  } else {
    semop(semid, &mysem, 1);
    mysem.sem_op = 1;
    semop(semid, &mysem, 1);
    array[1] += 1;
    for (int i = 0; i < 1000000000; i++)
      ;
    array[2] += 1;
    mysem.sem_op = -1;
    semop(semid, &mysem, 1);
  }
  printf(
      "Program 1 was spawn %d times, program 2 - %d times, total - %d times\n",
      array[0], array[1], array[2]);
  if (shmdt(array) < 0) {
    printf("Can't detach shared memory\n");
    exit(-1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    0xe64(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe5e(%rip),%ax
mov    %ax,-0x1e(%rbp)
lea    -0x22(%rbp),%rdi
xor    %esi,%esi
call   10a0 <ftok@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    11d9 <main+0x59>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%edi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
or     $0x1b6,%edx
mov    0x2dfe(%rip),%rax
or     (%rax),%edx
mov    $0xc,%esi
call   1070 <shmget@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    127b <main+0xfb>
mov    0x2dbf(%rip),%rax
mov    (%rax),%rax
mov    0x2dbd(%rip),%rcx
cmp    (%rcx),%rax
je     123c <main+0xbc>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%edi
mov    $0xc,%esi
xor    %edx,%edx
call   1070 <shmget@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    126f <main+0xef>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movl   $0x0,-0x1c(%rbp)
jmp    127b <main+0xfb>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <shmat@plt>
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    12b5 <main+0x135>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    -0x22(%rbp),%rdi
xor    %esi,%esi
call   10a0 <ftok@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    12e4 <main+0x164>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x2c(%rbp),%edi
mov    0x2cda(%rip),%rax
mov    (%rax),%edx
or     $0x1b6,%edx
mov    $0x1,%esi
call   1030 <semget@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1324 <main+0x1a4>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movl   $0x0,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     136a <main+0x1ea>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x8(%rax)
jmp    13ec <main+0x26c>
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x1,%edx
call   1080 <semop@plt>
movl   $0x1,-0x48(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x1,%edx
call   1080 <semop@plt>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x4(%rax)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x3b9aca00,-0x4c(%rbp)
jge    13c7 <main+0x247>
jmp    13b9 <main+0x239>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13a7 <main+0x227>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x8(%rax)
movl   $0xffffffff,-0x48(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x1,%edx
call   1080 <semop@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <shmdt@plt>
cmp    $0x0,%rax
jge    1439 <main+0x2b9>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movw   $0x33,0x4(%rsp)
movl   $0x706d6574,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   10b0 <ftok@plt>
test   %eax,%eax
js     130f <main+0x17f>
mov    %eax,%ebx
mov    0x2e07(%rip),%rbp
mov    0x0(%rbp),%edx
mov    0x2e25(%rip),%rax
or     (%rax),%edx
or     $0x1b6,%edx
mov    %ebx,%edi
mov    $0xc,%esi
call   1080 <shmget@plt>
mov    %eax,%r14d
mov    %eax,%edi
test   %eax,%eax
jns    121a <main+0x8a>
mov    0x2de1(%rip),%rax
mov    (%rax),%rax
mov    0x2ddf(%rip),%rcx
cmp    (%rcx),%rax
jne    133c <main+0x1ac>
mov    %ebx,%edi
mov    $0xc,%esi
xor    %edx,%edx
call   1080 <shmget@plt>
mov    %eax,%edi
test   %eax,%eax
js     1345 <main+0x1b5>
xor    %esi,%esi
xor    %edx,%edx
call   1070 <shmat@plt>
cmp    $0xffffffffffffffff,%rax
je     1318 <main+0x188>
mov    %rax,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   10b0 <ftok@plt>
test   %eax,%eax
js     1321 <main+0x191>
mov    $0x1b6,%edx
or     0x0(%rbp),%edx
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <semget@plt>
test   %eax,%eax
js     132a <main+0x19a>
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
test   %r14d,%r14d
js     1295 <main+0x105>
movabs $0x100000000,%rax
mov    %rax,(%rbx)
movl   $0x1,0x8(%rbx)
xor    %esi,%esi
mov    $0x1,%ecx
mov    $0x1,%edx
jmp    12e9 <main+0x159>
mov    %eax,%ebp
lea    0x8(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1090 <semop@plt>
movl   $0x1,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1090 <semop@plt>
addl   $0x1,0x4(%rbx)
addl   $0x1,0x8(%rbx)
movl   $0xffffffff,0x8(%rsp)
ff
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1090 <semop@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
lea    0xd16(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <shmdt@plt>
test   %rax,%rax
js     1333 <main+0x1a3>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdc7(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd6f(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd4f(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd36(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd12(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd7f(%rip),%rdi
jmp    134c <main+0x1bc>
lea    0xd5d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.sembuf = type { i32, i64, i64 }
@__const.main.pathname = [6 x i8] c"temp3\00"
@.str = [34 x i8] c"Can't generate shared memory key\0A\00"
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [28 x i8] c"Can't create shared memory\0A\00"
@.str.2 = [26 x i8] c"Can't find shared memory\0A\00"
@.str.3 = [28 x i8] c"Can't attach shared memory\0A\00"
@.str.4 = [24 x i8] c"Can't generate sem key\0A\00"
@.str.5 = [17 x i8] c"Can't get semid\0A\00"
@.str.6 = [70 x i8] c"Program 1 was spawn %d times, program 2 - %d times, total - %d times\0A\00"
@.str.7 = [28 x i8] c"Can't detach shared memory\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [6 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sembuf
%10 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
%11 = bitcast [6 x i8]* %6 to i8*
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%13 = call i32 @ftok(i8* %12, i32 0)
store i32 %13, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %0
%19 = load i32, i32* %7
%20 = load i32, i32* @IPC_CREAT
%21 = or i32 438, %20
%22 = load i32, i32* @IPC_EXCL
%23 = or i32 %21, %22
%24 = call i32 @shmget(i32 %19, i32 12, i32 %23)
store i32 %24, i32* %3
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %42
26: ; preds = %18
%27 = load i64, i64* @errno
%28 = load i64, i64* @EEXIST
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %26
%34 = load i32, i32* %7
%35 = call i32 @shmget(i32 %34, i32 12, i32 0)
store i32 %35, i32* %3
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %33
store i32 0, i32* %5
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41, %18
%43 = load i32, i32* %3
%44 = call i64 @shmat(i32 %43, i32* null, i32 0)
%45 = inttoptr i64 %44 to i32*
store i32* %45, i32** %2
%46 = icmp eq i32* %45, inttoptr (i64 -1 to i32*)
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %42
%51 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%52 = call i32 @ftok(i8* %51, i32 0)
store i32 %52, i32* %8
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %50
%58 = load i32, i32* %8
%59 = load i32, i32* @IPC_CREAT
%60 = or i32 438, %59
%61 = call i32 @semget(i32 %58, i32 1, i32 %60)
store i32 %61, i32* %4
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %57
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 @exit(i32 -1)
unreachable
66: ; preds = %57
%67 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 0
store i32 0, i32* %67
%68 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 2
store i64 0, i64* %68
%69 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 1
store i64 0, i64* %69
%70 = load i32, i32* %5
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %79
72: ; preds = %66
%73 = load i32*, i32** %2
%74 = getelementptr inbounds i32, i32* %73, i64 0
store i32 0, i32* %74
%75 = load i32*, i32** %2
%76 = getelementptr inbounds i32, i32* %75, i64 1
store i32 1, i32* %76
%77 = load i32*, i32** %2
%78 = getelementptr inbounds i32, i32* %77, i64 2
store i32 1, i32* %78
br label %104
79: ; preds = %66
%80 = load i32, i32* %4
%81 = call i32 @semop(i32 %80, %struct.sembuf* %9, i32 1)
%82 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 0
store i32 1, i32* %82
%83 = load i32, i32* %4
%84 = call i32 @semop(i32 %83, %struct.sembuf* %9, i32 1)
%85 = load i32*, i32** %2
%86 = getelementptr inbounds i32, i32* %85, i64 1
%87 = load i32, i32* %86
%88 = add nsw i32 %87, 1
store i32 %88, i32* %86
store i32 0, i32* %10
br label %89
89: ; preds = %93, %79
%90 = load i32, i32* %10
%91 = icmp slt i32 %90, 1000000000
br i1 %91, label %92, label %96
92: ; preds = %89
br label %93
93: ; preds = %92
%94 = load i32, i32* %10
%95 = add nsw i32 %94, 1
store i32 %95, i32* %10
br label %89
96: ; preds = %89
%97 = load i32*, i32** %2
%98 = getelementptr inbounds i32, i32* %97, i64 2
%99 = load i32, i32* %98
%100 = add nsw i32 %99, 1
store i32 %100, i32* %98
%101 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 0
store i32 -1, i32* %101
%102 = load i32, i32* %4
%103 = call i32 @semop(i32 %102, %struct.sembuf* %9, i32 1)
br label %104
104: ; preds = %96, %72
%105 = load i32*, i32** %2
%106 = getelementptr inbounds i32, i32* %105, i64 0
%107 = load i32, i32* %106
%108 = load i32*, i32** %2
%109 = getelementptr inbounds i32, i32* %108, i64 1
%110 = load i32, i32* %109
%111 = load i32*, i32** %2
%112 = getelementptr inbounds i32, i32* %111, i64 2
%113 = load i32, i32* %112
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.6, i64 0, i64 0), i32 %107, i32 %110, i32 %113)
%115 = load i32*, i32** %2
%116 = call i64 @shmdt(i32* %115)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %104
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%120 = call i32 @exit(i32 -1)
unreachable
121: ; preds = %104
ret i32 0
}

LLVM IR (-O2):
%struct.sembuf = type { i32, i64, i64 }
@__const.main.pathname = [6 x i8] c"temp3\00"
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.6 = [70 x i8] c"Program 1 was spawn %d times, program 2 - %d times, total - %d times\0A\00"
@str = [27 x i8] c"Can't detach shared memory\00"
@str.8 = [16 x i8] c"Can't get semid\00"
@str.9 = [23 x i8] c"Can't generate sem key\00"
@str.10 = [27 x i8] c"Can't attach shared memory\00"
@str.11 = [25 x i8] c"Can't find shared memory\00"
@str.12 = [27 x i8] c"Can't create shared memory\00"
@str.13 = [33 x i8] c"Can't generate shared memory key\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca %struct.sembuf
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.sembuf* %2 to i8*
%5 = call i32 @ftok(i8* %3, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = load i32, i32* @IPC_CREAT
%12 = load i32, i32* @IPC_EXCL
%13 = or i32 %11, %12
%14 = or i32 %13, 438
%15 = call i32 @shmget(i32 %5, i32 12, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %10
%18 = load i64, i64* @errno
%19 = load i64, i64* @EEXIST
%20 = icmp eq i64 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %17
%25 = call i32 @shmget(i32 %5, i32 12, i32 0)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %24, %10
%31 = phi i32 [ %15, %10 ], [ %25, %24 ]
%32 = call i64 @shmat(i32 %31, i32* null, i32 0)
%33 = inttoptr i64 %32 to i32*
%34 = icmp eq i32* %33, inttoptr (i64 -1 to i32*)
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %30
%39 = call i32 @ftok(i8* %3, i32 0)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%43 = call i32 @exit(i32 -1)
unreachable
44: ; preds = %38
%45 = load i32, i32* @IPC_CREAT
%46 = or i32 %45, 438
%47 = call i32 @semget(i32 %39, i32 1, i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %44
%53 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 0
store i32 0, i32* %53
%54 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 1
%55 = bitcast i64* %54 to i8*
br i1 %16, label %59, label %56
56: ; preds = %52
store i32 0, i32* %33
%57 = getelementptr inbounds i32, i32* %33, i64 1
store i32 1, i32* %57
%58 = getelementptr inbounds i32, i32* %33, i64 2
store i32 1, i32* %58
br label %72
59: ; preds = %52
%60 = call i32 @semop(i32 %47, %struct.sembuf* %2, i32 1)
store i32 1, i32* %53
%61 = call i32 @semop(i32 %47, %struct.sembuf* %2, i32 1)
%62 = getelementptr inbounds i32, i32* %33, i64 1
%63 = load i32, i32* %62
%64 = add nsw i32 %63, 1
store i32 %64, i32* %62
%65 = getelementptr inbounds i32, i32* %33, i64 2
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 1
store i32 %67, i32* %65
store i32 -1, i32* %53
%68 = call i32 @semop(i32 %47, %struct.sembuf* %2, i32 1)
%69 = load i32, i32* %33
%70 = load i32, i32* %62
%71 = load i32, i32* %65
br label %72
72: ; preds = %59, %56
%73 = phi i32 [ %71, %59 ], [ 1, %56 ]
%74 = phi i32 [ %70, %59 ], [ 1, %56 ]
%75 = phi i32 [ %69, %59 ], [ 0, %56 ]
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.6, i64 0, i64 0), i32 %75, i32 %74, i32 %73)
%77 = call i64 @shmdt(i32* %33)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %72
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %72
ret i32 0
}