#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*/ IPC_RMID;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ shmctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void removeSharedMemory(int shared_mem_id) {
  if (shmctl(shared_mem_id, IPC_RMID, NULL) != 0) {
    fprintf(stderr,
            "Impossivel remover o segmento de memoria compartilhada!\n");
    exit(1);
  } else {
    fprintf(stdout,
            "\nSegmento de memoria compartilhada removido com sucesso!");
  }
}


x86 assembly (clang, -O0):
<removeSharedMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <shmctl@plt>
cmp    $0x0,%rax
je     1179 <removeSharedMemory+0x49>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeSharedMemory>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <shmctl@plt>
test   %rax,%rax
jne    115c <removeSharedMemory+0x2c>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xee3(%rip),%rsi
pop    %rax
jmp    1030 <fprintf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@IPC_RMID = global i32 0
@stderr = global i32 0
@.str = [57 x i8] c"Impossivel remover o segmento de memoria compartilhada!\0A\00"
@stdout = global i32 0
@.str.1 = [57 x i8] c"\0ASegmento de memoria compartilhada removido com sucesso!\00"
define void @removeSharedMemory(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @IPC_RMID
%5 = call i64 @shmctl(i32 %3, i32 %4, i32* null)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = load i32, i32* @stdout
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11
ret void
}

LLVM IR (-O2):
@IPC_RMID = global i32 0
@stderr = global i32 0
@.str = [57 x i8] c"Impossivel remover o segmento de memoria compartilhada!\0A\00"
@stdout = global i32 0
@.str.1 = [57 x i8] c"\0ASegmento de memoria compartilhada removido com sucesso!\00"
define void @removeSharedMemory(i32 %0) {
%2 = load i32, i32* @IPC_RMID
%3 = tail call i64 @shmctl(i32 %0, i32 %2, i32* null)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = load i32, i32* @stdout
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
ret void
}