#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ consume(int, int *, int *, int *, int);
int create_semaphores(int);
void *create_shared_memory();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ handle_fatal_error(char *);
int /*<<< orphan*/ initialize_semaphore(int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ produce(int, int *, int *, int *, int);
scalar_t__ semctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  pid_t pid;
  void *shared_memory;
  int *buffer;
  int *in;
  int *out;
  int semid;
  int counter;
  shared_memory = create_shared_memory();
  buffer = (int *)shared_memory;
  in = (int *)shared_memory + 5 * sizeof(int);
  out = (int *)shared_memory + (5 + 1) * sizeof(int);
  *in = *out = 0;
  semid = create_semaphores(3);
  initialize_semaphore(semid, 0, 0);
  initialize_semaphore(semid, 1, 5);
  initialize_semaphore(semid, 2, 1);
  for (counter = 1; counter <= 6; counter++) {
    pid = fork();
    if (pid == -1) {
      handle_fatal_error("Error when trying to fork producers.\n");
    }
    if (pid == 0) {
      produce(counter, buffer, in, out, semid);
      exit(EXIT_SUCCESS);
    }
  }
  for (counter = 1; counter <= 5; counter++) {
    pid = fork();
    if (pid == -1) {
      handle_fatal_error("Error when trying to fork consumers.\n");
    }
    if (pid == 0) {
      consume(counter, buffer, in, out, semid);
      exit(EXIT_SUCCESS);
    }
  }
  printf("All producers and consumers are working.\n");
  printf("Parent process is waiting for them to end...\n");
  for (counter = 0; counter < 6 + 5; counter++) {
    wait(NULL);
  }
  if (semctl(semid, 0, IPC_RMID) < 0) {
    handle_fatal_error("Error removing semaphores.\n");
    exit(EXIT_FAILURE);
  }
  printf("Semaphores removed.\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <create_shared_memory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x50,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x60,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    $0x3,%edi
call   1090 <create_semaphores@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <initialize_semaphore@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
mov    $0x5,%edx
call   1030 <initialize_semaphore@plt>
mov    -0x2c(%rbp),%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <initialize_semaphore@plt>
movl   $0x1,-0x30(%rbp)
cmpl   $0x6,-0x30(%rbp)
jg     12af <main+0xff>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    126c <main+0xbc>
lea    0xd99(%rip),%rdi
call   1060 <handle_fatal_error@plt>
cmpl   $0x0,-0x8(%rbp)
jne    129c <main+0xec>
mov    -0x30(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1040 <produce@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    12a1 <main+0xf1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1242 <main+0x92>
movl   $0x1,-0x30(%rbp)
cmpl   $0x5,-0x30(%rbp)
jg     1323 <main+0x173>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    12e0 <main+0x130>
lea    0xd4b(%rip),%rdi
call   1060 <handle_fatal_error@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1310 <main+0x160>
mov    -0x30(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1070 <consume@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1315 <main+0x165>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12b6 <main+0x106>
lea    0xd22(%rip),%rdi
call   1050 <printf@plt>
lea    0xd40(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0xb,-0x30(%rbp)
jge    1363 <main+0x1b3>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <wait@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1342 <main+0x192>
mov    -0x2c(%rbp),%edi
mov    0x2c6b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <semctl@plt>
cmp    $0x0,%rax
jge    139a <main+0x1ea>
lea    0xd1d(%rip),%rdi
call   1060 <handle_fatal_error@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xd1f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   10c0 <create_shared_memory@plt>
mov    %rax,%rbx
lea    0x50(%rax),%r15
lea    0x60(%rax),%r14
movl   $0x0,0x60(%rax)
movl   $0x0,0x50(%rax)
mov    $0x3,%edi
call   1090 <create_semaphores@plt>
mov    %eax,%r12d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <initialize_semaphore@plt>
mov    $0x1,%ebp
mov    %r12d,%edi
mov    $0x1,%esi
mov    $0x5,%edx
call   1030 <initialize_semaphore@plt>
mov    %r12d,%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <initialize_semaphore@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1435 <main+0x285>
cmp    $0xffffffff,%eax
jne    1239 <main+0x89>
lea    0xdcc(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1414 <main+0x264>
cmp    $0xffffffff,%eax
jne    1259 <main+0xa9>
lea    0xdac(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     141b <main+0x26b>
cmp    $0xffffffff,%eax
jne    1279 <main+0xc9>
lea    0xd8c(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1422 <main+0x272>
cmp    $0xffffffff,%eax
jne    1299 <main+0xe9>
lea    0xd6c(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1429 <main+0x279>
cmp    $0xffffffff,%eax
jne    12b9 <main+0x109>
lea    0xd4c(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1430 <main+0x280>
cmp    $0xffffffff,%eax
jne    12d9 <main+0x129>
lea    0xd2c(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1456 <main+0x2a6>
cmp    $0xffffffff,%eax
jne    12f9 <main+0x149>
lea    0xd32(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     145d <main+0x2ad>
cmp    $0xffffffff,%eax
jne    1319 <main+0x169>
lea    0xd12(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1464 <main+0x2b4>
cmp    $0xffffffff,%eax
jne    1339 <main+0x189>
lea    0xcf2(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     146b <main+0x2bb>
cmp    $0xffffffff,%eax
jne    1359 <main+0x1a9>
lea    0xcd2(%rip),%rdi
call   1060 <handle_fatal_error@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     1472 <main+0x2c2>
cmp    $0xffffffff,%eax
jne    1379 <main+0x1c9>
lea    0xcb2(%rip),%rdi
call   1060 <handle_fatal_error@plt>
lea    0xce8(%rip),%rdi
call   1040 <puts@plt>
lea    0xd05(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1080 <semctl@plt>
test   %rax,%rax
jns    148a <main+0x2da>
lea    0xc4b(%rip),%rdi
call   1060 <handle_fatal_error@plt>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x2,%ebp
jmp    1435 <main+0x285>
mov    $0x3,%ebp
jmp    1435 <main+0x285>
mov    $0x4,%ebp
jmp    1435 <main+0x285>
mov    $0x5,%ebp
jmp    1435 <main+0x285>
mov    $0x6,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12d,%r8d
call   1050 <produce@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x1,%edi
jmp    1477 <main+0x2c7>
mov    $0x2,%edi
jmp    1477 <main+0x2c7>
mov    $0x3,%edi
jmp    1477 <main+0x2c7>
mov    $0x4,%edi
jmp    1477 <main+0x2c7>
mov    $0x5,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12d,%r8d
call   1070 <consume@plt>
jmp    1448 <main+0x298>
lea    0xc2d(%rip),%rdi
call   1040 <puts@plt>
jmp    1448 <main+0x298>

LLVM IR (-O0):
@.str = [38 x i8] c"Error when trying to fork producers.\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [38 x i8] c"Error when trying to fork consumers.\0A\00"
@.str.2 = [42 x i8] c"All producers and consumers are working.\0A\00"
@.str.3 = [46 x i8] c"Parent process is waiting for them to end...\0A\00"
@IPC_RMID = global i32 0
@.str.4 = [28 x i8] c"Error removing semaphores.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [21 x i8] c"Semaphores removed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i8* (...) @create_shared_memory()
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %4
%12 = load i8*, i8** %3
%13 = bitcast i8* %12 to i32*
%14 = getelementptr inbounds i32, i32* %13, i64 20
store i32* %14, i32** %5
%15 = load i8*, i8** %3
%16 = bitcast i8* %15 to i32*
%17 = getelementptr inbounds i32, i32* %16, i64 24
store i32* %17, i32** %6
%18 = load i32*, i32** %6
store i32 0, i32* %18
%19 = load i32*, i32** %5
store i32 0, i32* %19
%20 = call i32 @create_semaphores(i32 3)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = call i32 @initialize_semaphore(i32 %21, i32 0, i32 0)
%23 = load i32, i32* %7
%24 = call i32 @initialize_semaphore(i32 %23, i32 1, i32 5)
%25 = load i32, i32* %7
%26 = call i32 @initialize_semaphore(i32 %25, i32 2, i32 1)
store i32 1, i32* %8
br label %27
27: ; preds = %49, %0
%28 = load i32, i32* %8
%29 = icmp sle i32 %28, 6
br i1 %29, label %30, label %52
30: ; preds = %27
%31 = call i32 (...) @fork()
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
%37 = load i32, i32* %2
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32, i32* %8
%41 = load i32*, i32** %4
%42 = load i32*, i32** %5
%43 = load i32*, i32** %6
%44 = load i32, i32* %7
%45 = call i32 @produce(i32 %40, i32* %41, i32* %42, i32* %43, i32 %44)
%46 = load i32, i32* @EXIT_SUCCESS
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %36
br label %49
49: ; preds = %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %27
52: ; preds = %27
store i32 1, i32* %8
br label %53
53: ; preds = %75, %52
%54 = load i32, i32* %8
%55 = icmp sle i32 %54, 5
br i1 %55, label %56, label %78
56: ; preds = %53
%57 = call i32 (...) @fork()
store i32 %57, i32* %2
%58 = load i32, i32* %2
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %56
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %62
%66 = load i32, i32* %8
%67 = load i32*, i32** %4
%68 = load i32*, i32** %5
%69 = load i32*, i32** %6
%70 = load i32, i32* %7
%71 = call i32 @consume(i32 %66, i32* %67, i32* %68, i32* %69, i32 %70)
%72 = load i32, i32* @EXIT_SUCCESS
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %62
br label %75
75: ; preds = %74
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %53
78: ; preds = %53
%79 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%80 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %81
81: ; preds = %86, %78
%82 = load i32, i32* %8
%83 = icmp slt i32 %82, 11
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = call i32 @wait(i32* null)
br label %86
86: ; preds = %84
%87 = load i32, i32* %8
%88 = add nsw i32 %87, 1
store i32 %88, i32* %8
br label %81
89: ; preds = %81
%90 = load i32, i32* %7
%91 = load i32, i32* @IPC_RMID
%92 = call i64 @semctl(i32 %90, i32 0, i32 %91)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %98
94: ; preds = %89
%95 = call i32 @handle_fatal_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %89
%99 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%100 = load i32, i32* @EXIT_SUCCESS
%101 = call i32 @exit(i32 %100)
unreachable
}

LLVM IR (-O2):
@.str = [38 x i8] c"Error when trying to fork producers.\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [38 x i8] c"Error when trying to fork consumers.\0A\00"
@IPC_RMID = global i32 0
@.str.4 = [28 x i8] c"Error removing semaphores.\0A\00"
@EXIT_FAILURE = global i32 0
@str = [41 x i8] c"All producers and consumers are working.\00"
@str.6 = [45 x i8] c"Parent process is waiting for them to end...\00"
@str.7 = [20 x i8] c"Semaphores removed.\00"
define i32 @main() {
%1 = tail call i8* (...) @create_shared_memory()
%2 = bitcast i8* %1 to i32*
%3 = getelementptr inbounds i8, i8* %1, i64 80
%4 = bitcast i8* %3 to i32*
%5 = getelementptr inbounds i8, i8* %1, i64 96
%6 = bitcast i8* %5 to i32*
store i32 0, i32* %6
store i32 0, i32* %4
%7 = tail call i32 @create_semaphores(i32 3)
%8 = tail call i32 @initialize_semaphore(i32 %7, i32 0, i32 0)
%9 = tail call i32 @initialize_semaphore(i32 %7, i32 1, i32 5)
%10 = tail call i32 @initialize_semaphore(i32 %7, i32 2, i32 1)
%11 = tail call i32 (...) @fork()
switch i32 %11, label %19 [
i32 -1, label %12
i32 0, label %14
]
12: ; preds = %0
%13 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %19
14: ; preds = %35, %31, %27, %23, %19, %0
%15 = phi i32 [ 1, %0 ], [ 2, %19 ], [ 3, %23 ], [ 4, %27 ], [ 5, %31 ], [ 6, %35 ]
%16 = tail call i32 @produce(i32 %15, i32* %2, i32* %4, i32* %6, i32 %7)
%17 = load i32, i32* @EXIT_SUCCESS
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %12, %0
%20 = tail call i32 (...) @fork()
switch i32 %20, label %23 [
i32 -1, label %21
i32 0, label %14
]
21: ; preds = %19
%22 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = tail call i32 (...) @fork()
switch i32 %24, label %27 [
i32 -1, label %25
i32 0, label %14
]
25: ; preds = %23
%26 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = tail call i32 (...) @fork()
switch i32 %28, label %31 [
i32 -1, label %29
i32 0, label %14
]
29: ; preds = %27
%30 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = tail call i32 (...) @fork()
switch i32 %32, label %35 [
i32 -1, label %33
i32 0, label %14
]
33: ; preds = %31
%34 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = tail call i32 (...) @fork()
switch i32 %36, label %39 [
i32 -1, label %37
i32 0, label %14
]
37: ; preds = %35
%38 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = tail call i32 (...) @fork()
switch i32 %40, label %48 [
i32 -1, label %41
i32 0, label %43
]
41: ; preds = %39
%42 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %48
43: ; preds = %60, %56, %52, %48, %39
%44 = phi i32 [ 1, %39 ], [ 2, %48 ], [ 3, %52 ], [ 4, %56 ], [ 5, %60 ]
%45 = tail call i32 @consume(i32 %44, i32* %2, i32* %4, i32* %6, i32 %7)
%46 = load i32, i32* @EXIT_SUCCESS
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %41, %39
%49 = tail call i32 (...) @fork()
switch i32 %49, label %52 [
i32 -1, label %50
i32 0, label %43
]
50: ; preds = %48
%51 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
%53 = tail call i32 (...) @fork()
switch i32 %53, label %56 [
i32 -1, label %54
i32 0, label %43
]
54: ; preds = %52
%55 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
%57 = tail call i32 (...) @fork()
switch i32 %57, label %60 [
i32 -1, label %58
i32 0, label %43
]
58: ; preds = %56
%59 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
%61 = tail call i32 (...) @fork()
switch i32 %61, label %64 [
i32 -1, label %62
i32 0, label %43
]
62: ; preds = %60
%63 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %64
64: ; preds = %62, %60
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.6, i64 0, i64 0))
%67 = tail call i32 @wait(i32* null)
%68 = tail call i32 @wait(i32* null)
%69 = tail call i32 @wait(i32* null)
%70 = tail call i32 @wait(i32* null)
%71 = tail call i32 @wait(i32* null)
%72 = tail call i32 @wait(i32* null)
%73 = tail call i32 @wait(i32* null)
%74 = tail call i32 @wait(i32* null)
%75 = tail call i32 @wait(i32* null)
%76 = tail call i32 @wait(i32* null)
%77 = tail call i32 @wait(i32* null)
%78 = load i32, i32* @IPC_RMID
%79 = tail call i64 @semctl(i32 %7, i32 0, i32 %78)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %64
%82 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
%84 = tail call i32 @exit(i32 %83)
unreachable
85: ; preds = %64
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%87 = load i32, i32* @EXIT_SUCCESS
%88 = tail call i32 @exit(i32 %87)
unreachable
}