#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 scalar_t__ mqd_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ mq_close(scalar_t__);
scalar_t__ mq_open(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  mqd_t mqd;
  mqd = mq_open("/abc", O_RDWR | O_CREAT, 0666, NULL);
  if (mqd == (mqd_t)-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/day0c/mq_create.c",
              22, "mq_open", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  mq_close(mqd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2e89(%rip),%rax
or     (%rax),%esi
lea    0xe88(%rip),%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <mq_open@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0xffffffffffffffff,-0x10(%rbp)
jne    11e7 <main+0x97>
jmp    119a <main+0x4a>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%r9
lea    0xe44(%rip),%rsi
lea    0xe4d(%rip),%rdx
mov    $0x16,%ecx
lea    0xed9(%rip),%r8
call   1040 <fprintf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mq_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e88(%rip),%rax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe96(%rip),%rdi
mov    $0x1b6,%edx
xor    %ecx,%ecx
call   1050 <mq_open@plt>
cmp    $0xffffffffffffffff,%rax
je     1188 <main+0x38>
mov    %rax,%rdi
call   1030 <mq_close@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e41(%rip),%rax
mov    (%rax),%ebx
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe5f(%rip),%rsi
lea    0xe68(%rip),%rdx
lea    0xef9(%rip),%r8
mov    %ebx,%edi
mov    $0x16,%ecx
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"/abc\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.2 = [152 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/day0c/mq_create.c\00"
@.str.3 = [8 x i8] c"mq_open\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = load i32, i32* @O_RDWR
%4 = load i32, i32* @O_CREAT
%5 = or i32 %3, %4
%6 = call i64 @mq_open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5, i32 438, i32* null)
store i64 %6, i64* %2
%7 = load i64, i64* %2
%8 = icmp eq i64 %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.1, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, 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
%19 = load i64, i64* %2
%20 = call i32 @mq_close(i64 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"/abc\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.2 = [152 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/day0c/mq_create.c\00"
@.str.3 = [8 x i8] c"mq_open\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = tail call i64 @mq_open(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3, i32 438, i32* null)
%5 = icmp eq i64 %4, -1
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.2, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = tail call i32 @mq_close(i64 %4)
ret i32 0
}