#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 */
struct _citrus_region {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ *_citrus_region_head(struct _citrus_region *);
int /*<<< orphan*/ _citrus_region_init(struct _citrus_region *,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ _citrus_region_size(struct _citrus_region *);
int /*<<< orphan*/ munmap(int /*<<< orphan*/ *, int /*<<< orphan*/);
void _citrus_unmap_file(struct _citrus_region *r) {
  if (_citrus_region_head(r) != NULL) {
    (void)munmap(_citrus_region_head(r), _citrus_region_size(r));
    _citrus_region_init(r, NULL, 0);
  }
}


x86 assembly (clang, -O0):
<_citrus_unmap_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <_citrus_region_head@plt>
cmp    $0x0,%rax
je     118f <_citrus_unmap_file+0x4f>
mov    -0x8(%rbp),%rdi
call   1060 <_citrus_region_head@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_citrus_region_size@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <_citrus_region_init@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_unmap_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <_citrus_region_head@plt>
test   %rax,%rax
je     1181 <_citrus_unmap_file+0x41>
mov    %rbx,%rdi
call   1060 <_citrus_region_head@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <_citrus_region_size@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <munmap@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <_citrus_region_init@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct._citrus_region = type { i32 }
define void @_citrus_unmap_file(%struct._citrus_region* %0) {
%2 = alloca %struct._citrus_region*
store %struct._citrus_region* %0, %struct._citrus_region** %2
%3 = load %struct._citrus_region*, %struct._citrus_region** %2
%4 = call i32* @_citrus_region_head(%struct._citrus_region* %3)
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = load %struct._citrus_region*, %struct._citrus_region** %2
%8 = call i32* @_citrus_region_head(%struct._citrus_region* %7)
%9 = load %struct._citrus_region*, %struct._citrus_region** %2
%10 = call i32 @_citrus_region_size(%struct._citrus_region* %9)
%11 = call i32 @munmap(i32* %8, i32 %10)
%12 = load %struct._citrus_region*, %struct._citrus_region** %2
%13 = call i32 @_citrus_region_init(%struct._citrus_region* %12, i32* null, i32 0)
br label %14
14: ; preds = %6, %1
ret void
}

LLVM IR (-O2):
%struct._citrus_region = type { i32 }
define void @_citrus_unmap_file(%struct._citrus_region* %0) {
%2 = tail call i32* @_citrus_region_head(%struct._citrus_region* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32* @_citrus_region_head(%struct._citrus_region* %0)
%6 = tail call i32 @_citrus_region_size(%struct._citrus_region* %0)
%7 = tail call i32 @munmap(i32* %5, i32 %6)
%8 = tail call i32 @_citrus_region_init(%struct._citrus_region* %0, i32* null, i32 0)
br label %9
9: ; preds = %4, %1
ret void
}