#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*/ _DIAGASSERT(int /*<<< orphan*/);
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) {
  _DIAGASSERT(r != NULL);
  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)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <_DIAGASSERT@plt>
mov    -0x8(%rbp),%rdi
call   1070 <_citrus_region_head@plt>
cmp    $0x0,%rax
je     11b1 <_citrus_unmap_file+0x61>
mov    -0x8(%rbp),%rdi
call   1070 <_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   1060 <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
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <_DIAGASSERT@plt>
mov    %rbx,%rdi
call   1070 <_citrus_region_head@plt>
test   %rax,%rax
je     11a2 <_citrus_unmap_file+0x52>
mov    %rbx,%rdi
call   1070 <_citrus_region_head@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <_citrus_region_size@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <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 = icmp ne %struct._citrus_region* %3, null
%5 = zext i1 %4 to i32
%6 = call i32 @_DIAGASSERT(i32 %5)
%7 = load %struct._citrus_region*, %struct._citrus_region** %2
%8 = call i32* @_citrus_region_head(%struct._citrus_region* %7)
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = load %struct._citrus_region*, %struct._citrus_region** %2
%12 = call i32* @_citrus_region_head(%struct._citrus_region* %11)
%13 = load %struct._citrus_region*, %struct._citrus_region** %2
%14 = call i32 @_citrus_region_size(%struct._citrus_region* %13)
%15 = call i32 @munmap(i32* %12, i32 %14)
%16 = load %struct._citrus_region*, %struct._citrus_region** %2
%17 = call i32 @_citrus_region_init(%struct._citrus_region* %16, i32* null, i32 0)
br label %18
18: ; preds = %10, %1
ret void
}

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