#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 IPC_CREAT;
int IPC_EXCL;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int msgget(int, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  int id;
  if ((id = msgget(1234, IPC_CREAT | IPC_EXCL | 0666)) == -1)
    do {
      fprintf(stderr, "[%s][%d]:%s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day0a/day0a/msgcreate.c",
              22, "msgget", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
mov    0x2e91(%rip),%rax
or     (%rax),%esi
or     $0x1b6,%esi
mov    $0x4d2,%edi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11cf <main+0x8f>
jmp    1182 <main+0x42>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%r9
lea    0xe57(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    $0x16,%ecx
lea    0xef2(%rip),%r8
call   1040 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
mov    0x2e9f(%rip),%rax
or     (%rax),%esi
or     $0x1b6,%esi
mov    $0x4d2,%edi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
je     116c <main+0x2c>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e65(%rip),%rax
mov    (%rax),%ebx
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe76(%rip),%rsi
lea    0xe7f(%rip),%rdx
lea    0xf16(%rip),%r8
mov    %ebx,%edi
mov    $0x16,%ecx
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day0a/day0a/msgcreate.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @IPC_CREAT
%4 = load i32, i32* @IPC_EXCL
%5 = or i32 %3, %4
%6 = or i32 %5, 438
%7 = call i32 @msgget(i32 1234, i32 %6)
store i32 %7, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %18
9: ; preds = %0
br label %10
10: ; preds = %9
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; No predecessors!
br label %18
18: ; preds = %17, %0
ret i32 0
}

LLVM IR (-O2):
@IPC_CREAT = global i32 0
@IPC_EXCL = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day0a/day0a/msgcreate.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = load i32, i32* @IPC_CREAT
%2 = load i32, i32* @IPC_EXCL
%3 = or i32 %1, %2
%4 = or i32 %3, 438
%5 = tail call i32 @msgget(i32 1234, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.1, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
ret i32 0
}