#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*/ clean_up();
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);
int main(int argc, char *argv[]) {
  int *qids;
  int no_qs;
  int *mids;
  int no_ms;
  int big_ms;
  int max_1messages;
  int max_10messages;
  int max_msg_len;
  if (argc > 1) {
    clean_up();
  }
  max_1messages = test_no_messages(1);
  max_10messages = test_no_messages(10);
  max_msg_len = test_max_msg_len();
  no_ms = test_shmmni(&mids, 1);
  drop_mems(mids, no_ms);
  big_ms = test_shmmni(&mids, 4096);
  drop_mems(mids, no_ms);
  no_qs = test_msgmni(&qids);
  drop_queues(qids, no_qs);
  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);
  printf("       max number of %d memsegs = %d.\n", 4096, big_ms);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a7 <main+0x27>
mov    $0x0,%al
call   1050 <clean_up@plt>
mov    $0x1,%edi
call   1070 <test_no_messages@plt>
mov    %eax,-0x34(%rbp)
mov    $0xa,%edi
call   1070 <test_no_messages@plt>
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1090 <test_max_msg_len@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1060 <test_shmmni@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <drop_mems@plt>
lea    -0x28(%rbp),%rdi
mov    $0x1000,%esi
call   1060 <test_shmmni@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <drop_mems@plt>
lea    -0x18(%rbp),%rdi
call   1030 <test_msgmni@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10a0 <drop_queues@plt>
mov    -0x34(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%edx
lea    0xe3a(%rip),%rdi
mov    $0x1000,%esi
mov    $0x0,%al
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   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     119a <main+0x1a>
xor    %eax,%eax
call   1050 <clean_up@plt>
mov    $0x1,%edi
call   1070 <test_no_messages@plt>
mov    %eax,%r13d
mov    $0xa,%edi
call   1070 <test_no_messages@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1090 <test_max_msg_len@plt>
mov    %eax,%r15d
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
call   1060 <test_shmmni@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
mov    %eax,%esi
call   1080 <drop_mems@plt>
mov    %rbp,%rdi
mov    $0x1000,%esi
call   1060 <test_shmmni@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
call   1080 <drop_mems@plt>
lea    0x10(%rsp),%rdi
call   1030 <test_msgmni@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
mov    %eax,%esi
call   10a0 <drop_queues@plt>
lea    0xde7(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x1000,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
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"
@.str.5 = [39 x i8] c" max number of %d memsegs = %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (...) @clean_up()
br label %18
18: ; preds = %16, %2
%19 = call i32 @test_no_messages(i32 1)
store i32 %19, i32* %11
%20 = call i32 @test_no_messages(i32 10)
store i32 %20, i32* %12
%21 = call i32 (...) @test_max_msg_len()
store i32 %21, i32* %13
%22 = call i32 @test_shmmni(i32** %8, i32 1)
store i32 %22, i32* %9
%23 = load i32*, i32** %8
%24 = load i32, i32* %9
%25 = call i32 @drop_mems(i32* %23, i32 %24)
%26 = call i32 @test_shmmni(i32** %8, i32 4096)
store i32 %26, i32* %10
%27 = load i32*, i32** %8
%28 = load i32, i32* %9
%29 = call i32 @drop_mems(i32* %27, i32 %28)
%30 = call i32 @test_msgmni(i32** %6)
store i32 %30, i32* %7
%31 = load i32*, i32** %6
%32 = load i32, i32* %7
%33 = call i32 @drop_queues(i32* %31, i32 %32)
%34 = load i32, i32* %11
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %12
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %13
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %7
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %9
%43 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %10
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 4096, i32 %44)
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"
@.str.5 = [39 x i8] c" max number of %d memsegs = %d.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = bitcast i32** %3 to i8*
%6 = bitcast i32** %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (...) @clean_up()
br label %10
10: ; preds = %8, %2
%11 = tail call i32 @test_no_messages(i32 1)
%12 = tail call i32 @test_no_messages(i32 10)
%13 = tail call i32 (...) @test_max_msg_len()
%14 = call i32 @test_shmmni(i32** %4, i32 1)
%15 = load i32*, i32** %4
%16 = call i32 @drop_mems(i32* %15, i32 %14)
%17 = call i32 @test_shmmni(i32** %4, i32 4096)
%18 = load i32*, i32** %4
%19 = call i32 @drop_mems(i32* %18, i32 %14)
%20 = call i32 @test_msgmni(i32** %3)
%21 = load i32*, i32** %3
%22 = call i32 @drop_queues(i32* %21, i32 %20)
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %11)
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 4096, i32 %17)
ret i32 0
}