#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*/ error(char *, ...);
int /*<<< orphan*/ mb_error_to_string(int);
int mb_request_pages(int);
int /*<<< orphan*/ printf(char *, int, int);
void do_request(int n_pages) {
  int ret = mb_request_pages(n_pages);
  if (ret < 0) {
    error("mb_request_pages() said %s\n", mb_error_to_string(ret));
  }
  printf("Got %d of %d pages\n", ret, n_pages);
  if (ret == 0) {
    error("request failed\n");
  }
}


x86 assembly (clang, -O0):
<do_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <mb_request_pages@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1178 <do_request+0x38>
mov    -0x8(%rbp),%edi
call   1060 <mb_error_to_string@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1050 <error@plt>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a2 <do_request+0x62>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_request>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1040 <mb_request_pages@plt>
mov    %eax,%ebp
test   %eax,%eax
js     116b <do_request+0x2b>
lea    0xec5(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
test   %ebp,%ebp
je     1198 <do_request+0x58>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
call   1060 <mb_error_to_string@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <error@plt>
lea    0xe93(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <error@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"mb_request_pages() said %s\0A\00"
@.str.1 = [20 x i8] c"Got %d of %d pages\0A\00"
@.str.2 = [16 x i8] c"request failed\0A\00"
define void @do_request(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @mb_request_pages(i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @mb_error_to_string(i32 %9)
%11 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %8, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %12
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"mb_request_pages() said %s\0A\00"
@.str.1 = [20 x i8] c"Got %d of %d pages\0A\00"
@.str.2 = [16 x i8] c"request failed\0A\00"
define void @do_request(i32 %0) {
%2 = tail call i32 @mb_request_pages(i32 %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @mb_error_to_string(i32 %2)
%6 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %0)
br label %13
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %0)
%10 = icmp eq i32 %2, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %4, %11, %8
ret void
}