#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 uid;
  int gid;
  int cuid;
  int cgid;
};
struct shmid_ds {
  TYPE_1__ shm_perm;
  int /*<<< orphan*/ shm_lpid;
  int /*<<< orphan*/ shm_cpid;
  int /*<<< orphan*/ shm_ctime;
  int /*<<< orphan*/ shm_dtime;
  int /*<<< orphan*/ shm_atime;
  int /*<<< orphan*/ shm_segsz;
};

/* Variables and functions */
int /*<<< orphan*/ SHM_STAT;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int shmctl(int, int /*<<< orphan*/, struct shmid_ds *);
int infoSegment(int shmid) {
  struct shmid_ds shminfo;
  if ((shmctl(shmid, SHM_STAT, &shminfo)) == -1) {
    perror("shmctl");
    return -1;
  }
  printf("shm_perm_uid : %u\nshm_perm_gid : %u\nshm_perm_cuid : "
         "%u\nshm_perm_cgid : %u\nshm_segsz : %lu\nshm_atime : %lu\nshm_dtime "
         ": %lu\nshm_ctime : %lu\nshm_cpid : %u\nshm_lpid : %u\n",
         shminfo.shm_perm.uid, shminfo.shm_perm.gid, shminfo.shm_perm.cuid,
         shminfo.shm_perm.cgid, shminfo.shm_segsz, shminfo.shm_atime,
         shminfo.shm_dtime, shminfo.shm_ctime, shminfo.shm_cpid,
         shminfo.shm_lpid);
  return 0;
}


x86 assembly (clang, -O0):
<infoSegment>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %edi,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1040 <shmctl@plt>
cmp    $0xffffffff,%eax
jne    1174 <infoSegment+0x44>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    11c0 <infoSegment+0x90>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%r14d
mov    -0x24(%rbp),%ebx
mov    -0x28(%rbp),%r11d
mov    -0x2c(%rbp),%r10d
mov    -0x30(%rbp),%eax
lea    0xe69(%rip),%rdi
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<infoSegment>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1040 <shmctl@plt>
cmp    $0xffffffff,%eax
je     119f <infoSegment+0x6f>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x24(%rsp),%r9d
mov    0x20(%rsp),%r10d
mov    0x1c(%rsp),%r11d
mov    0x18(%rsp),%r14d
mov    0x14(%rsp),%ebx
mov    0x10(%rsp),%eax
sub    $0x8,%rsp
lea    0xe83(%rip),%rdi
push   %rax
push   %rbx
push   %r14
push   %r11
push   %r10
call   1030 <printf@plt>
add    $0x30,%rsp
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe5a(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
jmp    1197 <infoSegment+0x67>

LLVM IR (-O0):
%struct.shmid_ds = type { %struct.TYPE_2__, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@SHM_STAT = global i32 0
@.str = [7 x i8] c"shmctl\00"
@.str.1 = [167 x i8] c"shm_perm_uid : %u\0Ashm_perm_gid : %u\0Ashm_perm_cuid : %u\0Ashm_perm_cgid : %u\0Ashm_segsz : %lu\0Ashm_atime : %lu\0Ashm_dtime : %lu\0Ashm_ctime : %lu\0Ashm_cpid : %u\0Ashm_lpid : %u\0A\00"
define i32 @infoSegment(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.shmid_ds
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = load i32, i32* @SHM_STAT
%7 = call i32 @shmctl(i32 %5, i32 %6, %struct.shmid_ds* %4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %37
11: ; preds = %1
%12 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 6
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 5
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 4
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 3
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 2
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %4, i32 0, i32 1
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17, i32 %20, i32 %23, i32 %25, i32 %27, i32 %29, i32 %31, i32 %33, i32 %35)
store i32 0, i32* %2
br label %37
37: ; preds = %11, %9
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
%struct.shmid_ds = type { %struct.TYPE_2__, i32, i32, i32, i32, i32, i32 }
%struct.TYPE_2__ = type { i32, i32, i32, i32 }
@SHM_STAT = global i32 0
@.str = [7 x i8] c"shmctl\00"
@.str.1 = [167 x i8] c"shm_perm_uid : %u\0Ashm_perm_gid : %u\0Ashm_perm_cuid : %u\0Ashm_perm_cgid : %u\0Ashm_segsz : %lu\0Ashm_atime : %lu\0Ashm_dtime : %lu\0Ashm_ctime : %lu\0Ashm_cpid : %u\0Ashm_lpid : %u\0A\00"
define i32 @infoSegment(i32 %0) {
%2 = alloca %struct.shmid_ds
%3 = bitcast %struct.shmid_ds* %2 to i8*
%4 = load i32, i32* @SHM_STAT
%5 = call i32 @shmctl(i32 %0, i32 %4, %struct.shmid_ds* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %31
9: ; preds = %1
%10 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 0, i32 3
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 6
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 5
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 4
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 3
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 2
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 1
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25, i32 %27, i32 %29)
br label %31
31: ; preds = %9, %7
%32 = phi i32 [ -1, %7 ], [ 0, %9 ]
ret i32 %32
}