#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*/ IPC_RMID;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int msgctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int msgget(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  int id;
  if ((id = msgget(1234, 0)) == -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/msgrmid.c",
              21, "msgget", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  if (msgctl(id, IPC_RMID, NULL) == -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/msgrmid.c",
              24, "msgctl", 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    $0x4d2,%edi
xor    %esi,%esi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11c9 <main+0x79>
jmp    117c <main+0x2c>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%r9
lea    0xe5d(%rip),%rsi
lea    0xe66(%rip),%rdx
mov    $0x15,%ecx
lea    0xef6(%rip),%r8
call   1040 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    1239 <main+0xe9>
jmp    11ec <main+0x9c>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%r9
lea    0xded(%rip),%rsi
lea    0xdf6(%rip),%rdx
mov    $0x18,%ecx
lea    0xe8d(%rip),%r8
call   1040 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4d2,%edi
xor    %esi,%esi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
je     117d <main+0x2d>
mov    0x2e5f(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1050 <msgctl@plt>
cmp    $0xffffffff,%eax
je     11b2 <main+0x62>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e5c(%rip),%rax
mov    (%rax),%ebx
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe65(%rip),%rsi
lea    0xe6e(%rip),%rdx
lea    0xf03(%rip),%r8
mov    %ebx,%edi
mov    $0x15,%ecx
jmp    11e5 <main+0x95>
mov    0x2e27(%rip),%rax
mov    (%rax),%ebx
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe30(%rip),%rsi
lea    0xe39(%rip),%rdx
lea    0xed5(%rip),%r8
mov    %ebx,%edi
mov    $0x18,%ecx
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [156 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/msgrmid.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@IPC_RMID = global i32 0
@.str.3 = [7 x i8] c"msgctl\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @msgget(i32 1234, i32 0)
store i32 %3, i32* %2
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %14
5: ; preds = %0
br label %6
6: ; preds = %5
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; No predecessors!
br label %14
14: ; preds = %13, %0
%15 = load i32, i32* %2
%16 = load i32, i32* @IPC_RMID
%17 = call i32 @msgctl(i32 %15, i32 %16, i32* null)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %28
19: ; preds = %14
br label %20
20: ; preds = %19
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; No predecessors!
br label %28
28: ; preds = %27, %14
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [156 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/msgrmid.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@IPC_RMID = global i32 0
@.str.3 = [7 x i8] c"msgctl\00"
define i32 @main() {
%1 = tail call i32 @msgget(i32 1234, i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = load i32, i32* @errno
%6 = tail call i8* @strerror(i32 %5)
%7 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = load i32, i32* @IPC_RMID
%12 = tail call i32 @msgctl(i32 %1, i32 %11, i32* null)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %10
ret i32 0
}