#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 IPC_CREAT;
int msgget(int, int);
int /*<<< orphan*/ msgsnd(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main() {
  int id = msgget(0x8888, 0644 | IPC_CREAT);
  if (id == -1) {
    perror("msgget");
    return 1;
  }
  msgsnd(id, "hello, everyone!", 17, 0);
  msgsnd(id, "good morning, csd1208!", 23, 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
or     $0x1a4,%esi
mov    $0x8888,%edi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    117d <main+0x4d>
lea    0xe94(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <main+0x79>
mov    -0x8(%rbp),%edi
lea    0xe80(%rip),%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1040 <msgsnd@plt>
mov    -0x8(%rbp),%edi
lea    0xe7b(%rip),%rsi
mov    $0x17,%edx
xor    %ecx,%ecx
call   1040 <msgsnd@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2ea6(%rip),%rax
mov    $0x1a4,%esi
or     (%rax),%esi
mov    $0x8888,%edi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
je     1187 <main+0x57>
mov    %eax,%ebp
lea    0xeae(%rip),%rsi
xor    %ebx,%ebx
mov    %eax,%edi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1040 <msgsnd@plt>
lea    0xea8(%rip),%rsi
mov    %ebp,%edi
mov    $0x17,%edx
xor    %ecx,%ecx
call   1040 <msgsnd@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe72(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%ebx
jmp    117e <main+0x4e>

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@.str = [7 x i8] c"msgget\00"
@.str.1 = [17 x i8] c"hello, everyone!\00"
@.str.2 = [23 x i8] c"good morning, csd1208!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @IPC_CREAT
%4 = or i32 420, %3
%5 = call i32 @msgget(i32 34952, i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %15
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 @msgsnd(i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 17, i32 0)
%13 = load i32, i32* %2
%14 = call i32 @msgsnd(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 23, i32 0)
br label %15
15: ; preds = %10, %8
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@.str = [7 x i8] c"msgget\00"
@.str.1 = [17 x i8] c"hello, everyone!\00"
@.str.2 = [23 x i8] c"good morning, csd1208!\00"
define i32 @main() {
%1 = load i32, i32* @IPC_CREAT
%2 = or i32 %1, 420
%3 = tail call i32 @msgget(i32 34952, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %10
7: ; preds = %0
%8 = tail call i32 @msgsnd(i32 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 17, i32 0)
%9 = tail call i32 @msgsnd(i32 %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 23, i32 0)
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %11
}