#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_num;
  int sem_op;
  scalar_t__ sem_flg;
};

/* Variables and functions */
int IPC_CREAT;
int SHM_R;
int SHM_W;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int semget(int, int, int);
int semop(int, struct sembuf *, int);
scalar_t__ shmat(int, int /*<<< orphan*/ *, int);
int shmget(int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strtok(char *, char *);
int main() {
  int semaphore;
  if ((semaphore = semget(42421, 3, 0666 | IPC_CREAT)) == -1) {
    perror("ERROR CREATING THE SEMAPHORE");
  }
  int shmid;
  if ((shmid = shmget(42422, sizeof(char) * 10, 0666)) < 0) {
    perror("FAILED TO RESERVE SHARED MEMORY");
  }
  char *writers;
  if ((writers = (char *)shmat(shmid, NULL, SHM_R | SHM_W)) < 0) {
    perror("FAILED TO ATTACH SHARED MEMORY ON USER SPACE");
  }
  struct sembuf sem1_op;
  sem1_op.sem_num = 0;
  sem1_op.sem_op = 1;
  sem1_op.sem_flg = 0;
  struct sembuf sem1_prob;
  sem1_prob.sem_num = 0;
  sem1_prob.sem_op = -1;
  sem1_prob.sem_flg = 0;
  struct sembuf sem2_op;
  sem2_op.sem_num = 1;
  sem2_op.sem_op = 1;
  sem2_op.sem_flg = 0;
  struct sembuf sem2_prob;
  sem2_prob.sem_num = 1;
  sem2_prob.sem_op = -1;
  sem2_prob.sem_flg = 0;
  struct sembuf sem3_op;
  sem3_op.sem_num = 2;
  sem3_op.sem_op = 1;
  sem3_op.sem_flg = 0;
  struct sembuf sem3_prob;
  sem3_prob.sem_num = 2;
  sem3_prob.sem_op = -1;
  sem3_prob.sem_flg = 0;
  if (semop(semaphore, &sem1_prob, 1) == -1) {
    perror("ERROR DECREMENTING THE SEMAPHORE");
  }
  char buffer[12];
  fgets(buffer, 12, stdin);
  strtok(buffer, "\n");
  sprintf(writers, "%s", buffer);
  if (semop(semaphore, &sem3_op, 1) == -1) {
    perror("ERROR INCREMENTING THE SEMAPHORE");
  }
  if (semop(semaphore, &sem2_prob, 1) == -1) {
    perror("ERROR INCREMENTING THE SEMAPHORE");
  }
  int i = 0;
  while (i < 10 && writers[i] != '\0') {
    printf("\n");
    printf("%c", writers[i]);
    i++;
  }
  printf("\n");
  if (semop(semaphore, &sem1_op, 1) == -1) {
    perror("ERROR INCREMENTING THE SEMAPHORE");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
or     $0x1b6,%edx
mov    $0xa5b5,%edi
mov    $0x3,%esi
call   1030 <semget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11e8 <main+0x48>
lea    0xe1d(%rip),%rdi
call   1060 <perror@plt>
mov    $0xa5b6,%edi
mov    $0xa,%esi
mov    $0x1b6,%edx
call   1090 <shmget@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1214 <main+0x74>
lea    0xe0e(%rip),%rdi
call   1060 <perror@plt>
mov    -0xc(%rbp),%edi
mov    0x2dc2(%rip),%rax
mov    (%rax),%edx
mov    0x2da1(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <shmat@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jae    124c <main+0xac>
lea    0xdf6(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x1,-0x48(%rbp)
movl   $0x1,-0x44(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x1,-0x58(%rbp)
movl   $0xffffffff,-0x54(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x2,-0x68(%rbp)
movl   $0x1,-0x64(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0x2,-0x78(%rbp)
movl   $0xffffffff,-0x74(%rbp)
movq   $0x0,-0x70(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <semop@plt>
cmp    $0xffffffff,%eax
jne    12f6 <main+0x156>
lea    0xd79(%rip),%rdi
call   1060 <perror@plt>
lea    -0x84(%rbp),%rdi
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1050 <fgets@plt>
lea    -0x84(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1070 <strtok@plt>
mov    -0x18(%rbp),%rdi
lea    -0x84(%rbp),%rdx
lea    0xd58(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <semop@plt>
cmp    $0xffffffff,%eax
jne    1360 <main+0x1c0>
lea    0xd35(%rip),%rdi
call   1060 <perror@plt>
mov    -0x8(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <semop@plt>
cmp    $0xffffffff,%eax
jne    1386 <main+0x1e6>
lea    0xd0f(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x88(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x88(%rbp)
mov    %al,-0x89(%rbp)
jge    13c0 <main+0x220>
mov    -0x18(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%al
test   $0x1,%al
jne    13d3 <main+0x233>
jmp    1412 <main+0x272>
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1390 <main+0x1f0>
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <semop@plt>
cmp    $0xffffffff,%eax
jne    1446 <main+0x2a6>
lea    0xc4f(%rip),%rdi
call   1060 <perror@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    0x2e21(%rip),%rax
mov    $0x1b6,%edx
or     (%rax),%edx
mov    $0xa5b5,%edi
mov    $0x3,%esi
call   1030 <semget@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    11d9 <main+0x39>
lea    0xe2c(%rip),%rdi
call   1070 <perror@plt>
mov    $0xa5b6,%edi
mov    $0xa,%esi
mov    $0x1b6,%edx
call   10a0 <shmget@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11ff <main+0x5f>
lea    0xe23(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dda(%rip),%rax
mov    0x2dbb(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1090 <shmat@plt>
mov    %rax,%rbx
movabs $0x100000000,%rax
mov    %rax,0x30(%rsp)
movq   $0x0,0x38(%rsp)
movabs $0xffffffff00000000,%rax
ff ff ff
mov    %rax,0x20(%rsp)
movq   $0x0,0x28(%rsp)
movabs $0xffffffff00000001,%rax
ff ff ff
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
movabs $0x100000002,%rax
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x20(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   10b0 <semop@plt>
cmp    $0xffffffff,%eax
jne    129f <main+0xff>
lea    0xda3(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edx
lea    0x44(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xc,%esi
call   1060 <fgets@plt>
lea    0xd9d(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strtok@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   10b0 <semop@plt>
cmp    $0xffffffff,%eax
jne    12f5 <main+0x155>
lea    0xd70(%rip),%rdi
call   1070 <perror@plt>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   10b0 <semop@plt>
cmp    $0xffffffff,%eax
jne    1318 <main+0x178>
lea    0xd4d(%rip),%rdi
call   1070 <perror@plt>
cmpb   $0x0,(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl (%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x1(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x1(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x2(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x2(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x3(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x3(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x4(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x4(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x5(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x5(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x6(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x6(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x7(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x7(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x8(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x8(%rbx),%edi
call   1040 <putchar@plt>
cmpb   $0x0,0x9(%rbx)
je     1424 <main+0x284>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0x9(%rbx),%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x30(%rsp),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   10b0 <semop@plt>
cmp    $0xffffffff,%eax
jne    1451 <main+0x2b1>
lea    0xc14(%rip),%rdi
call   1070 <perror@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.sembuf = type { i32, i32, i64 }
@IPC_CREAT = global i32 0
@.str = [29 x i8] c"ERROR CREATING THE SEMAPHORE\00"
@.str.1 = [32 x i8] c"FAILED TO RESERVE SHARED MEMORY\00"
@SHM_R = global i32 0
@SHM_W = global i32 0
@.str.2 = [45 x i8] c"FAILED TO ATTACH SHARED MEMORY ON USER SPACE\00"
@.str.3 = [33 x i8] c"ERROR DECREMENTING THE SEMAPHORE\00"
@stdin = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [33 x i8] c"ERROR INCREMENTING THE SEMAPHORE\00"
@.str.7 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.sembuf
%6 = alloca %struct.sembuf
%7 = alloca %struct.sembuf
%8 = alloca %struct.sembuf
%9 = alloca %struct.sembuf
%10 = alloca %struct.sembuf
%11 = alloca [12 x i8]
%12 = alloca i32
store i32 0, i32* %1
%13 = load i32, i32* @IPC_CREAT
%14 = or i32 438, %13
%15 = call i32 @semget(i32 42421, i32 3, i32 %14)
store i32 %15, i32* %2
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %0
%20 = call i32 @shmget(i32 42422, i32 10, i32 438)
store i32 %20, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = load i32, i32* %3
%26 = load i32, i32* @SHM_R
%27 = load i32, i32* @SHM_W
%28 = or i32 %26, %27
%29 = call i64 @shmat(i32 %25, i32* null, i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %4
%31 = icmp ult i8* %30, null
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %24
%35 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %5, i32 0, i32 0
store i32 0, i32* %35
%36 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %5, i32 0, i32 1
store i32 1, i32* %36
%37 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %5, i32 0, i32 2
store i64 0, i64* %37
%38 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %6, i32 0, i32 0
store i32 0, i32* %38
%39 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %6, i32 0, i32 1
store i32 -1, i32* %39
%40 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %6, i32 0, i32 2
store i64 0, i64* %40
%41 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %7, i32 0, i32 0
store i32 1, i32* %41
%42 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %7, i32 0, i32 1
store i32 1, i32* %42
%43 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %7, i32 0, i32 2
store i64 0, i64* %43
%44 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 0
store i32 1, i32* %44
%45 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 1
store i32 -1, i32* %45
%46 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %8, i32 0, i32 2
store i64 0, i64* %46
%47 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 0
store i32 2, i32* %47
%48 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 1
store i32 1, i32* %48
%49 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %9, i32 0, i32 2
store i64 0, i64* %49
%50 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %10, i32 0, i32 0
store i32 2, i32* %50
%51 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %10, i32 0, i32 1
store i32 -1, i32* %51
%52 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %10, i32 0, i32 2
store i64 0, i64* %52
%53 = load i32, i32* %2
%54 = call i32 @semop(i32 %53, %struct.sembuf* %6, i32 1)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %34
%57 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %34
%59 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%60 = load i32, i32* @stdin
%61 = call i32 @fgets(i8* %59, i32 12, i32 %60)
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%63 = call i32 @strtok(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%64 = load i8*, i8** %4
%65 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%66 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %65)
%67 = load i32, i32* %2
%68 = call i32 @semop(i32 %67, %struct.sembuf* %9, i32 1)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %72
70: ; preds = %58
%71 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %72
72: ; preds = %70, %58
%73 = load i32, i32* %2
%74 = call i32 @semop(i32 %73, %struct.sembuf* %8, i32 1)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %76, %72
store i32 0, i32* %12
br label %79
79: ; preds = %92, %78
%80 = load i32, i32* %12
%81 = icmp slt i32 %80, 10
br i1 %81, label %82, label %90
82: ; preds = %79
%83 = load i8*, i8** %4
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp ne i32 %88, 0
br label %90
90: ; preds = %82, %79
%91 = phi i1 [ false, %79 ], [ %89, %82 ]
br i1 %91, label %92, label %103
92: ; preds = %90
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%94 = load i8*, i8** %4
%95 = load i32, i32* %12
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %99)
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %79
103: ; preds = %90
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%105 = load i32, i32* %2
%106 = call i32 @semop(i32 %105, %struct.sembuf* %5, i32 1)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %103
%109 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %110
110: ; preds = %108, %103
%111 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sembuf = type { i32, i32, i64 }
@IPC_CREAT = global i32 0
@.str = [29 x i8] c"ERROR CREATING THE SEMAPHORE\00"
@.str.1 = [32 x i8] c"FAILED TO RESERVE SHARED MEMORY\00"
@SHM_R = global i32 0
@SHM_W = global i32 0
@.str.3 = [33 x i8] c"ERROR DECREMENTING THE SEMAPHORE\00"
@stdin = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
@.str.6 = [33 x i8] c"ERROR INCREMENTING THE SEMAPHORE\00"
define i32 @main() {
%1 = alloca %struct.sembuf
%2 = alloca %struct.sembuf
%3 = alloca %struct.sembuf
%4 = alloca %struct.sembuf
%5 = alloca [12 x i8]
%6 = load i32, i32* @IPC_CREAT
%7 = or i32 %6, 438
%8 = tail call i32 @semget(i32 42421, i32 3, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = tail call i32 @shmget(i32 42422, i32 10, i32 438)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* @SHM_R
%19 = load i32, i32* @SHM_W
%20 = or i32 %19, %18
%21 = tail call i64 @shmat(i32 %13, i32* null, i32 %20)
%22 = inttoptr i64 %21 to i8*
%23 = bitcast %struct.sembuf* %1 to i8*
%24 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %1, i64 0, i32 0
store i32 0, i32* %24
%25 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %1, i64 0, i32 1
store i32 1, i32* %25
%26 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %1, i64 0, i32 2
store i64 0, i64* %26
%27 = bitcast %struct.sembuf* %2 to i8*
%28 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 0
store i32 0, i32* %28
%29 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 1
store i32 -1, i32* %29
%30 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %2, i64 0, i32 2
store i64 0, i64* %30
%31 = bitcast %struct.sembuf* %3 to i8*
%32 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 0
store i32 1, i32* %32
%33 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 1
store i32 -1, i32* %33
%34 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %3, i64 0, i32 2
store i64 0, i64* %34
%35 = bitcast %struct.sembuf* %4 to i8*
%36 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i64 0, i32 0
store i32 2, i32* %36
%37 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i64 0, i32 1
store i32 1, i32* %37
%38 = getelementptr inbounds %struct.sembuf, %struct.sembuf* %4, i64 0, i32 2
store i64 0, i64* %38
%39 = call i32 @semop(i32 %8, %struct.sembuf* %2, i32 1)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %17
%42 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %17
%44 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%45 = load i32, i32* @stdin
%46 = call i32 @fgets(i8* %44, i32 12, i32 %45)
%47 = call i32 @strtok(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = call i8* @strcpy(i8* dereferenceable(1) %22, i8* %44)
%49 = call i32 @semop(i32 %8, %struct.sembuf* %4, i32 1)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %53
53: ; preds = %51, %43
%54 = call i32 @semop(i32 %8, %struct.sembuf* %3, i32 1)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
%59 = load i8, i8* %22
%60 = icmp eq i8 %59, 0
br i1 %60, label %138, label %61
61: ; preds = %58
%62 = call i32 @putchar(i32 10)
%63 = load i8, i8* %22
%64 = sext i8 %63 to i32
%65 = call i32 @putchar(i32 %64)
%66 = getelementptr inbounds i8, i8* %22, i64 1
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 0
br i1 %68, label %138, label %69
69: ; preds = %61
%70 = call i32 @putchar(i32 10)
%71 = load i8, i8* %66
%72 = sext i8 %71 to i32
%73 = call i32 @putchar(i32 %72)
%74 = getelementptr inbounds i8, i8* %22, i64 2
%75 = load i8, i8* %74
%76 = icmp eq i8 %75, 0
br i1 %76, label %138, label %77
77: ; preds = %69
%78 = call i32 @putchar(i32 10)
%79 = load i8, i8* %74
%80 = sext i8 %79 to i32
%81 = call i32 @putchar(i32 %80)
%82 = getelementptr inbounds i8, i8* %22, i64 3
%83 = load i8, i8* %82
%84 = icmp eq i8 %83, 0
br i1 %84, label %138, label %85
85: ; preds = %77
%86 = call i32 @putchar(i32 10)
%87 = load i8, i8* %82
%88 = sext i8 %87 to i32
%89 = call i32 @putchar(i32 %88)
%90 = getelementptr inbounds i8, i8* %22, i64 4
%91 = load i8, i8* %90
%92 = icmp eq i8 %91, 0
br i1 %92, label %138, label %93
93: ; preds = %85
%94 = call i32 @putchar(i32 10)
%95 = load i8, i8* %90
%96 = sext i8 %95 to i32
%97 = call i32 @putchar(i32 %96)
%98 = getelementptr inbounds i8, i8* %22, i64 5
%99 = load i8, i8* %98
%100 = icmp eq i8 %99, 0
br i1 %100, label %138, label %101
101: ; preds = %93
%102 = call i32 @putchar(i32 10)
%103 = load i8, i8* %98
%104 = sext i8 %103 to i32
%105 = call i32 @putchar(i32 %104)
%106 = getelementptr inbounds i8, i8* %22, i64 6
%107 = load i8, i8* %106
%108 = icmp eq i8 %107, 0
br i1 %108, label %138, label %109
109: ; preds = %101
%110 = call i32 @putchar(i32 10)
%111 = load i8, i8* %106
%112 = sext i8 %111 to i32
%113 = call i32 @putchar(i32 %112)
%114 = getelementptr inbounds i8, i8* %22, i64 7
%115 = load i8, i8* %114
%116 = icmp eq i8 %115, 0
br i1 %116, label %138, label %117
117: ; preds = %109
%118 = call i32 @putchar(i32 10)
%119 = load i8, i8* %114
%120 = sext i8 %119 to i32
%121 = call i32 @putchar(i32 %120)
%122 = getelementptr inbounds i8, i8* %22, i64 8
%123 = load i8, i8* %122
%124 = icmp eq i8 %123, 0
br i1 %124, label %138, label %125
125: ; preds = %117
%126 = call i32 @putchar(i32 10)
%127 = load i8, i8* %122
%128 = sext i8 %127 to i32
%129 = call i32 @putchar(i32 %128)
%130 = getelementptr inbounds i8, i8* %22, i64 9
%131 = load i8, i8* %130
%132 = icmp eq i8 %131, 0
br i1 %132, label %138, label %133
133: ; preds = %125
%134 = call i32 @putchar(i32 10)
%135 = load i8, i8* %130
%136 = sext i8 %135 to i32
%137 = call i32 @putchar(i32 %136)
br label %138
138: ; preds = %133, %125, %117, %109, %101, %93, %85, %77, %69, %61, %58
%139 = call i32 @putchar(i32 10)
%140 = call i32 @semop(i32 %8, %struct.sembuf* %1, i32 1)
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %144
142: ; preds = %138
%143 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %144
144: ; preds = %142, %138
%145 = call i32 @exit(i32 0)
unreachable
}