#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*/ get_index_name();
scalar_t__ munmap(int *, int);
int /*<<< orphan*/ shm_error(char *);
scalar_t__ shm_unlink(int /*<<< orphan*/);
int /*<<< orphan*/ trace_flow(char *);
void unmap_index(int *index) {
  if (1) {
    trace_flow("ENTERING: unmap_index");
  }
  if (munmap(index, sizeof(int)) != 0) {
    shm_error("munmap");
  }
  if (shm_unlink(get_index_name()) != 0) {
    shm_error("shm_unlink");
  }
  if (1) {
    trace_flow("LEAVING: unmap_index");
  }
}


x86 assembly (clang, -O0):
<unmap_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1060 <trace_flow@plt>
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1050 <munmap@plt>
cmp    $0x0,%rax
je     118c <unmap_index+0x3c>
lea    0xe8f(%rip),%rdi
call   1030 <shm_error@plt>
mov    $0x0,%al
call   1040 <get_index_name@plt>
mov    %eax,%edi
call   1070 <shm_unlink@plt>
cmp    $0x0,%rax
je     11b0 <unmap_index+0x60>
lea    0xe72(%rip),%rdi
call   1030 <shm_error@plt>
lea    0xe71(%rip),%rdi
call   1060 <trace_flow@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unmap_index>:
push   %rbx
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
call   1060 <trace_flow@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <munmap@plt>
test   %rax,%rax
je     117e <unmap_index+0x2e>
lea    0xe9d(%rip),%rdi
call   1030 <shm_error@plt>
xor    %eax,%eax
call   1040 <get_index_name@plt>
mov    %eax,%edi
call   1070 <shm_unlink@plt>
test   %rax,%rax
je     119d <unmap_index+0x4d>
lea    0xe85(%rip),%rdi
call   1030 <shm_error@plt>
lea    0xe84(%rip),%rdi
pop    %rbx
jmp    1060 <trace_flow@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"ENTERING: unmap_index\00"
@.str.1 = [7 x i8] c"munmap\00"
@.str.2 = [11 x i8] c"shm_unlink\00"
@.str.3 = [21 x i8] c"LEAVING: unmap_index\00"
define void @unmap_index(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = call i32 @trace_flow(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = load i32*, i32** %2
%5 = call i64 @munmap(i32* %4, i32 4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @shm_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = call i32 (...) @get_index_name()
%11 = call i64 @shm_unlink(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @shm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = call i32 @trace_flow(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"ENTERING: unmap_index\00"
@.str.1 = [7 x i8] c"munmap\00"
@.str.2 = [11 x i8] c"shm_unlink\00"
@.str.3 = [21 x i8] c"LEAVING: unmap_index\00"
define void @unmap_index(i32* %0) {
%2 = tail call i32 @trace_flow(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @munmap(i32* %0, i32 4)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @shm_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = tail call i32 (...) @get_index_name()
%9 = tail call i64 @shm_unlink(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @shm_error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = tail call i32 @trace_flow(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
ret void
}