#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*/ drop_mems(int *, int);
int /*<<< orphan*/ drop_queues(int *, int);
int /*<<< orphan*/ printf(char *, int);
int test_max_msg_len();
int test_msgmni(int **);
int test_no_messages(int);
int test_shmmni(int **);
int main(void) {
  int *qids;
  int no_qs;
  int *mids;
  int no_ms;
  int i;
  int max_1messages;
  int max_10messages;
  int max_msg_len;
  max_1messages = test_no_messages(1);
  max_10messages = test_no_messages(10);
  max_msg_len = test_max_msg_len();
  no_ms = test_shmmni(&mids);
  no_qs = test_msgmni(&qids);
  drop_queues(qids, no_qs);
  drop_mems(mids, no_ms);
  printf("MSGTQL max 1 byte messages  = %d.\n", max_1messages);
  printf("       max 10 byte messages = %d.\n", max_10messages);
  printf("MSGMAX max message length = %d.\n", max_msg_len);
  printf("MSGMNI max number of message queues = %d.\n", no_qs);
  printf("SHMMNI max number of memsegs = %d.\n", no_ms);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1060 <test_no_messages@plt>
mov    %eax,-0x2c(%rbp)
mov    $0xa,%edi
call   1060 <test_no_messages@plt>
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   1080 <test_max_msg_len@plt>
mov    %eax,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <test_shmmni@plt>
mov    %eax,-0x24(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <test_msgmni@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <drop_queues@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <drop_mems@plt>
mov    -0x2c(%rbp),%esi
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1060 <test_no_messages@plt>
mov    %eax,%r15d
mov    $0xa,%edi
call   1060 <test_no_messages@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1080 <test_max_msg_len@plt>
mov    %eax,%r12d
mov    %rsp,%rdi
call   1050 <test_shmmni@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1030 <test_msgmni@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
mov    %eax,%esi
call   1090 <drop_queues@plt>
mov    (%rsp),%rdi
mov    %ebx,%esi
call   1070 <drop_mems@plt>
lea    0xe2c(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"MSGTQL max 1 byte messages = %d.\0A\00"
@.str.1 = [35 x i8] c" max 10 byte messages = %d.\0A\00"
@.str.2 = [33 x i8] c"MSGMAX max message length = %d.\0A\00"
@.str.3 = [43 x i8] c"MSGMNI max number of message queues = %d.\0A\00"
@.str.4 = [36 x i8] c"SHMMNI max number of memsegs = %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 @test_no_messages(i32 1)
store i32 %10, i32* %7
%11 = call i32 @test_no_messages(i32 10)
store i32 %11, i32* %8
%12 = call i32 (...) @test_max_msg_len()
store i32 %12, i32* %9
%13 = call i32 @test_shmmni(i32** %4)
store i32 %13, i32* %5
%14 = call i32 @test_msgmni(i32** %2)
store i32 %14, i32* %3
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = call i32 @drop_queues(i32* %15, i32 %16)
%18 = load i32*, i32** %4
%19 = load i32, i32* %5
%20 = call i32 @drop_mems(i32* %18, i32 %19)
%21 = load i32, i32* %7
%22 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %8
%24 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %9
%26 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %5
%30 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"MSGTQL max 1 byte messages = %d.\0A\00"
@.str.1 = [35 x i8] c" max 10 byte messages = %d.\0A\00"
@.str.2 = [33 x i8] c"MSGMAX max message length = %d.\0A\00"
@.str.3 = [43 x i8] c"MSGMNI max number of message queues = %d.\0A\00"
@.str.4 = [36 x i8] c"SHMMNI max number of memsegs = %d.\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = tail call i32 @test_no_messages(i32 1)
%6 = tail call i32 @test_no_messages(i32 10)
%7 = tail call i32 (...) @test_max_msg_len()
%8 = call i32 @test_shmmni(i32** %2)
%9 = call i32 @test_msgmni(i32** %1)
%10 = load i32*, i32** %1
%11 = call i32 @drop_queues(i32* %10, i32 %9)
%12 = load i32*, i32** %2
%13 = call i32 @drop_mems(i32* %12, i32 %8)
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %5)
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%16 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%17 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %8)
ret i32 0
}