#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 /*<<< orphan*/ echo_svr(int);
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 | 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/echo/echo_svr.c",
              47, "msget", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  echo_svr(id);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
or     $0x1b6,%esi
mov    $0x4d2,%edi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11d6 <main+0x86>
jmp    1189 <main+0x39>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%r9
lea    0xe50(%rip),%rsi
lea    0xe59(%rip),%rdx
mov    $0x2f,%ecx
lea    0xeef(%rip),%r8
call   1050 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1040 <echo_svr@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e70(%rip),%rax
mov    $0x1b6,%esi
or     (%rax),%esi
mov    $0x4d2,%edi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
je     1179 <main+0x29>
mov    %eax,%edi
call   1040 <echo_svr@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e60(%rip),%rax
mov    (%rax),%ebx
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe69(%rip),%rsi
lea    0xe72(%rip),%rdx
lea    0xf0d(%rip),%r8
mov    %ebx,%edi
mov    $0x2f,%ecx
mov    %rax,%r9
call   1050 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@IPC_CREAT = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [162 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/echo/echo_svr.c\00"
@.str.2 = [6 x i8] c"msget\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 = or i32 %3, 438
%5 = call i32 @msgget(i32 1234, i32 %4)
store i32 %5, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %16
7: ; preds = %0
br label %8
8: ; preds = %7
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.1, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; No predecessors!
br label %16
16: ; preds = %15, %0
%17 = load i32, i32* %2
%18 = call i32 @echo_svr(i32 %17)
ret i32 0
}

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