#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ semctl(int, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
void removeSemaphore(int semaphore_id) {
  if (semctl(semaphore_id, 0, IPC_RMID, 0) != 0) {
    fprintf(stderr,
            "Impossivel remover o conjunto de semaforos! Error: %s\n semaphore "
            "id: %d",
            strerror(errno), semaphore_id);
    exit(1);
  } else {
    fprintf(stdout, "\nConjunto de semaforos removido com sucesso!");
  }
}


x86 assembly (clang, -O0):
<removeSemaphore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
mov    %ecx,%esi
call   1040 <semctl@plt>
cmp    $0x0,%rax
je     11a5 <removeSemaphore+0x65>
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x8(%rbp),%edi
mov    %rax,%rdx
mov    -0x4(%rbp),%ecx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeSemaphore>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <semctl@plt>
test   %rax,%rax
jne    1179 <removeSemaphore+0x39>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%ebp
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe69(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@IPC_RMID = global i32 0
@stderr = global i32 0
@.str = [72 x i8] c"Impossivel remover o conjunto de semaforos! Error: %s\0A semaphore id: %d\00"
@errno = global i32 0
@stdout = global i32 0
@.str.1 = [45 x i8] c"\0AConjunto de semaforos removido com sucesso!\00"
define void @removeSemaphore(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @IPC_RMID
%5 = call i64 @semctl(i32 %3, i32 0, i32 %4, i32 0)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = load i32, i32* %2
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14
ret void
}

LLVM IR (-O2):
@IPC_RMID = global i32 0
@stderr = global i32 0
@.str = [72 x i8] c"Impossivel remover o conjunto de semaforos! Error: %s\0A semaphore id: %d\00"
@errno = global i32 0
@stdout = global i32 0
@.str.1 = [45 x i8] c"\0AConjunto de semaforos removido com sucesso!\00"
define void @removeSemaphore(i32 %0) {
%2 = load i32, i32* @IPC_RMID
%3 = tail call i64 @semctl(i32 %0, i32 0, i32 %2, i32 0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = load i32, i32* @stdout
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
ret void
}