#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 */
typedef int /*<<< orphan*/ key_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ IPC_RMID;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ shmctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int shmget(int /*<<< orphan*/, int, int /*<<< orphan*/);
void remove_it(void) {
  int shmid;
  if ((shmid = shmget((key_t)26, 8196, 0)) == -1) {
    perror("shmget");
    exit(errno);
  };
  if (shmctl(shmid, IPC_RMID, 0)) {
    perror("shmctl");
    exit(errno);
  };
  printf("Marked shared memory segment for deletion\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<remove_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1a,%edi
mov    $0x2004,%esi
xor    %edx,%edx
call   1060 <shmget@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
jne    118f <remove_it+0x3f>
lea    0xe84(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <shmctl@plt>
cmp    $0x0,%rax
je     11c6 <remove_it+0x76>
lea    0xe54(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<remove_it>:
push   %rax
mov    $0x1a,%edi
mov    $0x2004,%esi
xor    %edx,%edx
call   1060 <shmget@plt>
cmp    $0xffffffff,%eax
jne    1170 <remove_it+0x20>
lea    0xe92(%rip),%rdi
jmp    11a8 <remove_it+0x58>
mov    0x2e61(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1040 <shmctl@plt>
test   %rax,%rax
jne    11a1 <remove_it+0x51>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe5f(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"shmget\00"
@errno = global i32 0
@IPC_RMID = global i32 0
@.str.1 = [7 x i8] c"shmctl\00"
@.str.2 = [43 x i8] c"Marked shared memory segment for deletion\0A\00"
@EXIT_SUCCESS = global i32 0
define void @remove_it() {
%1 = alloca i32
%2 = call i32 @shmget(i32 26, i32 8196, i32 0)
store i32 %2, i32* %1
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @errno
%7 = call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = load i32, i32* %1
%10 = load i32, i32* @IPC_RMID
%11 = call i64 @shmctl(i32 %9, i32 %10, i32 0)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @errno
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
%18 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"shmget\00"
@errno = global i32 0
@IPC_RMID = global i32 0
@.str.1 = [7 x i8] c"shmctl\00"
@EXIT_SUCCESS = global i32 0
@str = [42 x i8] c"Marked shared memory segment for deletion\00"
define void @remove_it() {
%1 = tail call i32 @shmget(i32 26, i32 8196, i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @errno
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %0
%8 = load i32, i32* @IPC_RMID
%9 = tail call i64 @shmctl(i32 %1, i32 %8, i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @errno
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %7
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_SUCCESS
%18 = tail call i32 @exit(i32 %17)
unreachable
}