#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int mode;
};
struct msqid_ds {
  int msg_qnum;
  int __msg_cbytes;
  TYPE_1__ msg_perm;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ IPC_STAT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int msgctl(int, int /*<<< orphan*/, struct msqid_ds *);
int msgget(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(void) {
  int id;
  struct msqid_ds buf;
  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/msgstat.c",
              22, "msgget", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  if (msgctl(id, IPC_STAT, &buf) == -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/msgstat.c",
              25, "msgctl", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  printf("permission:%o\n", buf.msg_perm.mode);
  printf("msg No.:%d\n", buf.msg_qnum);
  printf("bytes:%d\n", buf.__msg_cbytes);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4d2,%edi
xor    %esi,%esi
call   1030 <msgget@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11d9 <main+0x79>
jmp    118c <main+0x2c>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%r9
lea    0xe4d(%rip),%rsi
lea    0xe56(%rip),%rdx
mov    $0x16,%ecx
lea    0xee6(%rip),%r8
call   1050 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1060 <msgctl@plt>
cmp    $0xffffffff,%eax
jne    1249 <main+0xe9>
jmp    11fc <main+0x9c>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%r9
lea    0xddd(%rip),%rsi
lea    0xde6(%rip),%rdx
mov    $0x19,%ecx
lea    0xe7d(%rip),%r8
call   1050 <fprintf@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x4d2,%edi
xor    %esi,%esi
call   1030 <msgget@plt>
cmp    $0xffffffff,%eax
je     11c5 <main+0x65>
mov    0x2e5b(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rdx
mov    %eax,%edi
call   1060 <msgctl@plt>
cmp    $0xffffffff,%eax
je     11fa <main+0x9a>
mov    0x8(%rsp),%esi
lea    0xf21(%rip),%rdi
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xf21(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xf1d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e14(%rip),%rax
mov    (%rax),%ebx
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe1d(%rip),%rsi
lea    0xe26(%rip),%rdx
lea    0xebb(%rip),%r8
mov    %ebx,%edi
mov    $0x16,%ecx
jmp    122d <main+0xcd>
mov    0x2ddf(%rip),%rax
mov    (%rax),%ebx
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xde8(%rip),%rsi
lea    0xdf1(%rip),%rdx
lea    0xe8d(%rip),%r8
mov    %ebx,%edi
mov    $0x19,%ecx
mov    %rax,%r9
call   1050 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.msqid_ds = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@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/msgstat.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@IPC_STAT = global i32 0
@.str.3 = [7 x i8] c"msgctl\00"
@.str.4 = [15 x i8] c"permission:%o\0A\00"
@.str.5 = [12 x i8] c"msg No.:%d\0A\00"
@.str.6 = [10 x i8] c"bytes:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.msqid_ds
store i32 0, i32* %1
%4 = call i32 @msgget(i32 1234, i32 0)
store i32 %4, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %15
6: ; preds = %0
br label %7
7: ; preds = %6
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, 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 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 = call i32 @exit(i32 %12)
unreachable
14: ; No predecessors!
br label %15
15: ; preds = %14, %0
%16 = load i32, i32* %2
%17 = load i32, i32* @IPC_STAT
%18 = call i32 @msgctl(i32 %16, i32 %17, %struct.msqid_ds* %3)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %29
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 @fprintf(i32 %22, 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 25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; No predecessors!
br label %29
29: ; preds = %28, %15
%30 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 2
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %3, i32 0, i32 1
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
%struct.msqid_ds = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@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/msgstat.c\00"
@.str.2 = [7 x i8] c"msgget\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@IPC_STAT = global i32 0
@.str.3 = [7 x i8] c"msgctl\00"
@.str.4 = [15 x i8] c"permission:%o\0A\00"
@.str.5 = [12 x i8] c"msg No.:%d\0A\00"
@.str.6 = [10 x i8] c"bytes:%d\0A\00"
define i32 @main() {
%1 = alloca %struct.msqid_ds
%2 = bitcast %struct.msqid_ds* %1 to i8*
%3 = tail call i32 @msgget(i32 1234, i32 0)
%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 ([156 x i8], [156 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* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = load i32, i32* @IPC_STAT
%14 = call i32 @msgctl(i32 %3, i32 %13, %struct.msqid_ds* %1)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32 %17, 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 25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %12
%24 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %1, i64 0, i32 2, i32 0
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %1, i64 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.msqid_ds, %struct.msqid_ds* %1, i64 0, i32 1
%31 = load i32, i32* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %31)
ret i32 0
}