#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 */
struct msqid_ds {
  int dummy;
};
struct msginfo {
  scalar_t__ msgmax;
  scalar_t__ msgmap;
  scalar_t__ msgpool;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ MSG_INFO;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int msgctl(int /*<<< orphan*/, int /*<<< orphan*/, struct msqid_ds *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long);
int main(int argc, char *argv[]) {
  struct msginfo info;
  int s;
  s = msgctl(0, MSG_INFO, (struct msqid_ds *)&info);
  if (s == -1)
    perror("msgctl");
  printf("Maximum ID index = %d\n", s);
  printf("queues in_use    = %ld\n", (long)info.msgpool);
  printf("msg_hdrs         = %ld\n", (long)info.msgmap);
  printf("msg_bytes        = %ld\n", (long)info.msgmax);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
xor    %edi,%edi
call   1040 <msgctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1183 <main+0x43>
lea    0xe82(%rip),%rdi
call   1050 <perror@plt>
movslq -0x2c(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1040 <msgctl@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    116d <main+0x2d>
lea    0xe98(%rip),%rdi
call   1050 <perror@plt>
movslq %ebx,%rsi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.msginfo = type { i64, i64, i64 }
%struct.msqid_ds = type { i32 }
@MSG_INFO = global i32 0
@.str = [7 x i8] c"msgctl\00"
@.str.1 = [23 x i8] c"Maximum ID index = %d\0A\00"
@.str.2 = [24 x i8] c"queues in_use = %ld\0A\00"
@.str.3 = [24 x i8] c"msg_hdrs = %ld\0A\00"
@.str.4 = [24 x i8] c"msg_bytes = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.msginfo
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @MSG_INFO
%9 = bitcast %struct.msginfo* %6 to %struct.msqid_ds*
%10 = call i32 @msgctl(i32 0, i32 %8, %struct.msqid_ds* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %6, i32 0, i32 2
%20 = load i64, i64* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i64 %20)
%22 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %6, i32 0, i32 1
%23 = load i64, i64* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %23)
%25 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %6, i32 0, i32 0
%26 = load i64, i64* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 %26)
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}

LLVM IR (-O2):
%struct.msginfo = type { i64, i64, i64 }
%struct.msqid_ds = type { i32 }
@MSG_INFO = global i32 0
@.str = [7 x i8] c"msgctl\00"
@.str.1 = [23 x i8] c"Maximum ID index = %d\0A\00"
@.str.2 = [24 x i8] c"queues in_use = %ld\0A\00"
@.str.3 = [24 x i8] c"msg_hdrs = %ld\0A\00"
@.str.4 = [24 x i8] c"msg_bytes = %ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.msginfo
%4 = bitcast %struct.msginfo* %3 to i8*
%5 = load i32, i32* @MSG_INFO
%6 = bitcast %struct.msginfo* %3 to %struct.msqid_ds*
%7 = call i32 @msgctl(i32 0, i32 %5, %struct.msqid_ds* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = sext i32 %7 to i64
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%14 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %3, i64 0, i32 2
%15 = load i64, i64* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %3, i64 0, i32 1
%18 = load i64, i64* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %18)
%20 = getelementptr inbounds %struct.msginfo, %struct.msginfo* %3, i64 0, i32 0
%21 = load i64, i64* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 %21)
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @exit(i32 %23)
unreachable
}