#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__ {
  char *mode;
  int uid;
  int gid;
};
struct shmid_ds {
  int shm_segsz;
  int shm_cpid;
  int shm_lpid;
  TYPE_1__ shm_perm;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ IPC_STAT;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(struct shmid_ds *, int /*<<< orphan*/, int);
int /*<<< orphan*/ shmctl(int, int /*<<< orphan*/, struct shmid_ds *);
int /*<<< orphan*/ stderr;
int StatShm(int shmid) {
  char resp[20];
  struct shmid_ds buf;
  memset(&buf, 0, sizeof(buf));
  shmctl(shmid, IPC_STAT, &buf);
  fprintf(stderr, "T    ID    KEY    MODE    OWNER    GROUP    NATTCH    SEGSZ "
                  "   CPID    LPID\n");
  fprintf(stderr, "m %6d %10s %10d  %10d %10d %10d %10d\n", shmid,
          buf.shm_perm.mode, buf.shm_perm.uid, buf.shm_perm.gid, buf.shm_segsz,
          buf.shm_cpid, buf.shm_lpid);
}


x86 assembly (clang, -O0):
<StatShm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1050 <shmctl@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x40(%rbp),%r11d
mov    -0x3c(%rbp),%r10d
mov    -0x38(%rbp),%eax
lea    0xeac(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StatShm>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r15d
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r14,%rdx
call   1050 <shmctl@plt>
mov    0x2e74(%rip),%r14
mov    (%r14),%edi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8d
mov    0x24(%rsp),%r9d
mov    0x8(%rsp),%r10d
mov    0xc(%rsp),%ebx
mov    0x10(%rsp),%ebp
sub    $0x8,%rsp
lea    0xea6(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
push   %rbp
push   %rbx
push   %r10
call   1040 <fprintf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.shmid_ds = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i8*, i32, i32 }
@IPC_STAT = global i32 0
@stderr = global i32 0
@.str = [77 x i8] c"T ID KEY MODE OWNER GROUP NATTCH SEGSZ CPID LPID\0A\00"
@.str.1 = [38 x i8] c"m %6d %10s %10d %10d %10d %10d %10d\0A\00"
define i32 @StatShm(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca %struct.shmid_ds
store i32 %0, i32* %3
%6 = call i32 @memset(%struct.shmid_ds* %5, i32 0, i32 32)
%7 = load i32, i32* %3
%8 = load i32, i32* @IPC_STAT
%9 = call i32 @shmctl(i32 %7, i32 %8, %struct.shmid_ds* %5)
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = load i32, i32* %3
%14 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 3
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 3
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 3
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 1
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %5, i32 0, i32 2
%28 = load i32, i32* %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %16, i32 %19, i32 %22, i32 %24, i32 %26, i32 %28)
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.shmid_ds = type { i32, i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i8*, i32, i32 }
@IPC_STAT = global i32 0
@stderr = global i32 0
@.str = [77 x i8] c"T ID KEY MODE OWNER GROUP NATTCH SEGSZ CPID LPID\0A\00"
@.str.1 = [38 x i8] c"m %6d %10s %10d %10d %10d %10d %10d\0A\00"
define i32 @StatShm(i32 %0) {
%2 = alloca %struct.shmid_ds
%3 = bitcast %struct.shmid_ds* %2 to i8*
%4 = call i32 @memset(%struct.shmid_ds* %2, i32 0, i32 32)
%5 = load i32, i32* @IPC_STAT
%6 = call i32 @shmctl(i32 %0, i32 %5, %struct.shmid_ds* %2)
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 3, i32 0
%11 = load i8*, i8** %10
%12 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 3, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 3, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.shmid_ds, %struct.shmid_ds* %2, i64 0, i32 2
%21 = load i32, i32* %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %11, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21)
ret i32 undef
}