#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int IPC_CREAT;
int /*<<< orphan*/ IPC_PRIVATE;
int /*<<< orphan*/ WUNTRACED;
int create_auctioneer(int);
int create_client(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getpid();
int msgget(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  printf("[main] Started main.\t\tPid: %d\n", getpid());
  fflush(stdout);
  int master_msqid = msgget(IPC_PRIVATE, 0600 | IPC_CREAT);
  int auctnr_exit = create_auctioneer(master_msqid);
  if (auctnr_exit == 0) {
    int i = 0;
    for (i = 0; i < 5; i++) {
      int client_exit = create_client(master_msqid, i);
      if (client_exit != 0)
        exit(EXIT_FAILURE);
    }
    int processes = 5 + 1;
    while (processes > 0) {
      int p_status = 0;
      waitpid(-1, &p_status, WUNTRACED);
      processes--;
    }
    exit(EXIT_SUCCESS);
  }
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
or     $0x180,%esi
call   1030 <msgget@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <create_auctioneer@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    128a <main+0x10a>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    123f <main+0xbf>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10a0 <create_client@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     122c <main+0xac>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1231 <main+0xb1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fc <main+0x7c>
movl   $0x6,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    127c <main+0xfc>
movl   $0x0,-0x28(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x28(%rbp),%rsi
call   1070 <waitpid@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1246 <main+0xc6>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    0x2e01(%rip),%rax
mov    $0x180,%esi
or     (%rax),%esi
call   1030 <msgget@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <create_auctioneer@plt>
test   %eax,%eax
jne    12df <main+0x15f>
mov    %ebx,%edi
xor    %esi,%esi
call   10a0 <create_client@plt>
test   %eax,%eax
jne    12df <main+0x15f>
mov    %ebx,%edi
mov    $0x1,%esi
call   10a0 <create_client@plt>
test   %eax,%eax
jne    12df <main+0x15f>
mov    %ebx,%edi
mov    $0x2,%esi
call   10a0 <create_client@plt>
test   %eax,%eax
jne    12df <main+0x15f>
mov    %ebx,%edi
mov    $0x3,%esi
call   10a0 <create_client@plt>
test   %eax,%eax
jne    12df <main+0x15f>
mov    %ebx,%edi
mov    $0x4,%esi
call   10a0 <create_client@plt>
test   %eax,%eax
jne    12df <main+0x15f>
movl   $0x0,0x4(%rsp)
mov    0x2d94(%rip),%r14
mov    (%r14),%edx
lea    0x4(%rsp),%rbx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
movl   $0x0,0x4(%rsp)
mov    (%r14),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
movl   $0x0,0x4(%rsp)
mov    (%r14),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
movl   $0x0,0x4(%rsp)
mov    (%r14),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
movl   $0x0,0x4(%rsp)
mov    (%r14),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
movl   $0x0,0x4(%rsp)
mov    (%r14),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1070 <waitpid@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"[main] Started main.\09\09Pid: %d\0A\00"
@stdout = global i32 0
@IPC_PRIVATE = global i32 0
@IPC_CREAT = global i32 0
@EXIT_FAILURE = global i32 0
@WUNTRACED = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (...) @getpid()
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = load i32, i32* @IPC_PRIVATE
%17 = load i32, i32* @IPC_CREAT
%18 = or i32 384, %17
%19 = call i32 @msgget(i32 %16, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call i32 @create_auctioneer(i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %2
store i32 0, i32* %8
store i32 0, i32* %8
br label %25
25: ; preds = %38, %24
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 5
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = call i32 @create_client(i32 %29, i32 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %28
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %25
41: ; preds = %25
store i32 6, i32* %10
br label %42
42: ; preds = %45, %41
%43 = load i32, i32* %10
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %42
store i32 0, i32* %11
%46 = load i32, i32* @WUNTRACED
%47 = call i32 @waitpid(i32 -1, i32* %11, i32 %46)
%48 = load i32, i32* %10
%49 = add nsw i32 %48, -1
store i32 %49, i32* %10
br label %42
50: ; preds = %42
%51 = load i32, i32* @EXIT_SUCCESS
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %2
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
}

LLVM IR (-O2):
@.str = [31 x i8] c"[main] Started main.\09\09Pid: %d\0A\00"
@stdout = global i32 0
@IPC_PRIVATE = global i32 0
@IPC_CREAT = global i32 0
@EXIT_FAILURE = global i32 0
@WUNTRACED = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fflush(i32 %6)
%8 = load i32, i32* @IPC_PRIVATE
%9 = load i32, i32* @IPC_CREAT
%10 = or i32 %9, 384
%11 = tail call i32 @msgget(i32 %8, i32 %10)
%12 = tail call i32 @create_auctioneer(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %48
14: ; preds = %2
%15 = tail call i32 @create_client(i32 %11, i32 0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = tail call i32 @create_client(i32 %11, i32 1)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %45
20: ; preds = %17
%21 = tail call i32 @create_client(i32 %11, i32 2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %45
23: ; preds = %20
%24 = tail call i32 @create_client(i32 %11, i32 3)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %23
%27 = tail call i32 @create_client(i32 %11, i32 4)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %45
29: ; preds = %26
%30 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%31 = load i32, i32* @WUNTRACED
%32 = call i32 @waitpid(i32 -1, i32* %3, i32 %31)
store i32 0, i32* %3
%33 = load i32, i32* @WUNTRACED
%34 = call i32 @waitpid(i32 -1, i32* %3, i32 %33)
store i32 0, i32* %3
%35 = load i32, i32* @WUNTRACED
%36 = call i32 @waitpid(i32 -1, i32* %3, i32 %35)
store i32 0, i32* %3
%37 = load i32, i32* @WUNTRACED
%38 = call i32 @waitpid(i32 -1, i32* %3, i32 %37)
store i32 0, i32* %3
%39 = load i32, i32* @WUNTRACED
%40 = call i32 @waitpid(i32 -1, i32* %3, i32 %39)
store i32 0, i32* %3
%41 = load i32, i32* @WUNTRACED
%42 = call i32 @waitpid(i32 -1, i32* %3, i32 %41)
%43 = load i32, i32* @EXIT_SUCCESS
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %26, %23, %20, %17, %14
%46 = load i32, i32* @EXIT_FAILURE
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %2
%49 = load i32, i32* @EXIT_FAILURE
%50 = tail call i32 @exit(i32 %49)
unreachable
}