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

/* Variables and functions */
scalar_t__ close(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int munmap(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
void io_int_funmmap(int32_t *fmap, int64_t len, int32_t ifd) {
  if (fmap == NULL) {
    return;
  }
  if (munmap(fmap, len * sizeof(int32_t)) == -1) {
    fprintf(stderr, "unable to un-mmap() file");
  }
  fmap = NULL;
  if (close(ifd)) {
    fprintf(stderr, "unable to close the mmap()-ed file");
  }
  return;
}


x86 assembly (clang, -O0):
<io_int_funmmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1152 <io_int_funmmap+0x22>
jmp    11b7 <io_int_funmmap+0x87>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <munmap@plt>
cmp    $0xffffffff,%eax
jne    1183 <io_int_funmmap+0x53>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
cmp    $0x0,%rax
je     11b2 <io_int_funmmap+0x82>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b7 <io_int_funmmap+0x87>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_int_funmmap>:
push   %rbx
test   %rdi,%rdi
je     117c <io_int_funmmap+0x4c>
mov    %edx,%ebx
shl    $0x2,%esi
call   1050 <munmap@plt>
cmp    $0xffffffff,%eax
jne    115a <io_int_funmmap+0x2a>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%edi
call   1030 <close@plt>
test   %rax,%rax
je     117c <io_int_funmmap+0x4c>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
pop    %rbx
jmp    1040 <fprintf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"unable to un-mmap() file\00"
@.str.1 = [35 x i8] c"unable to close the mmap()-ed file\00"
define void @io_int_funmmap(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %3
br label %29
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i32 @munmap(i32* %11, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %18, %10
store i32* null, i32** %4
%22 = load i32, i32* %6
%23 = call i64 @close(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %21
br label %29
29: ; preds = %28, %9
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"unable to un-mmap() file\00"
@.str.1 = [35 x i8] c"unable to close the mmap()-ed file\00"
define void @io_int_funmmap(i32* %0, i32 %1, i32 %2) {
%4 = icmp eq i32* %0, null
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = shl i32 %1, 2
%7 = tail call i32 @munmap(i32* %0, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %5
%13 = tail call i64 @close(i32 %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %12, %15, %3
ret void
}