#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 /*<<< orphan*/ __u8;
typedef scalar_t__ __u32;
typedef int /*<<< orphan*/ __s32;

/* Variables and functions */
scalar_t__ axisGetReadBufferCount(int /*<<< orphan*/);
scalar_t__ axisGetReadBufferSize(int /*<<< orphan*/);
int /*<<< orphan*/ free(int /*<<< orphan*/ **);
int /*<<< orphan*/ munmap(int /*<<< orphan*/ **, scalar_t__);
void axisUnMapUser(__s32 fd, __u8 **buffer) {
  __u32 bCount;
  __u32 bSize;
  __u32 x;
  ;
  bCount = axisGetReadBufferCount(fd);
  bSize = axisGetReadBufferSize(fd);
  for (x = 0; x < bCount; x++)
    munmap(buffer, bSize);
  free(buffer);
}


x86 assembly (clang, -O0):
<axisUnMapUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <axisGetReadBufferCount@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <axisGetReadBufferSize@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    119b <axisUnMapUser+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <munmap@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116f <axisUnMapUser+0x2f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<axisUnMapUser>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
call   1050 <axisGetReadBufferCount@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <axisGetReadBufferSize@plt>
test   %rbx,%rbx
jle    1181 <axisUnMapUser+0x41>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <munmap@plt>
add    $0xffffffffffffffff,%rbx
jne    1170 <axisUnMapUser+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @axisUnMapUser(i32 %0, i32** %1) {
%3 = alloca i32
%4 = alloca i32**
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %3
store i32** %1, i32*** %4
%8 = load i32, i32* %3
%9 = call i64 @axisGetReadBufferCount(i32 %8)
store i64 %9, i64* %5
%10 = load i32, i32* %3
%11 = call i64 @axisGetReadBufferSize(i32 %10)
store i64 %11, i64* %6
store i64 0, i64* %7
br label %12
12: ; preds = %20, %2
%13 = load i64, i64* %7
%14 = load i64, i64* %5
%15 = icmp slt i64 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32**, i32*** %4
%18 = load i64, i64* %6
%19 = call i32 @munmap(i32** %17, i64 %18)
br label %20
20: ; preds = %16
%21 = load i64, i64* %7
%22 = add nsw i64 %21, 1
store i64 %22, i64* %7
br label %12
23: ; preds = %12
%24 = load i32**, i32*** %4
%25 = call i32 @free(i32** %24)
ret void
}

LLVM IR (-O2):
define void @axisUnMapUser(i32 %0, i32** %1) {
%3 = tail call i64 @axisGetReadBufferCount(i32 %0)
%4 = tail call i64 @axisGetReadBufferSize(i32 %0)
%5 = icmp sgt i64 %3, 0
br i1 %5, label %6, label %11
6: ; preds = %2, %6
%7 = phi i64 [ %9, %6 ], [ 0, %2 ]
%8 = tail call i32 @munmap(i32** %1, i64 %4)
%9 = add nuw nsw i64 %7, 1
%10 = icmp eq i64 %9, %3
br i1 %10, label %11, label %6
11: ; preds = %6, %2
%12 = tail call i32 @free(i32** %1)
ret void
}