#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 shmid_ds {
  int dummy;
};
struct shm_info {
  scalar_t__ swap_successes;
  scalar_t__ swap_attempts;
  scalar_t__ shm_swp;
  scalar_t__ shm_rss;
  scalar_t__ shm_tot;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ SHM_INFO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long);
int shmctl(int /*<<< orphan*/, int /*<<< orphan*/, struct shmid_ds *);
int main() {
  struct shm_info info;
  int s;
  s = shmctl(0, SHM_INFO, (struct shmid_ds *)&info);
  if (s == -1) {
    perror("shmctl");
    exit(1);
  }
  printf("Maximum ID index = %d\n", s);
  printf("shm_tot          = %ld\n", (long)info.shm_tot);
  printf("shm_rss          = %ld\n", (long)info.shm_rss);
  printf("shm_swp          = %ld\n", (long)info.shm_swp);
  printf("swap_attempts    = %ld\n", (long)info.swap_attempts);
  printf("swap_successes   = %ld\n", (long)info.swap_successes);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
xor    %edi,%edi
call   1040 <shmctl@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1186 <main+0x46>
lea    0xe89(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movslq -0x34(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1040 <shmctl@plt>
cmp    $0xffffffff,%eax
jne    1172 <main+0x32>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movslq %eax,%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%rsi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

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

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