#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*/ uint8_t;

/* Variables and functions */
scalar_t__ dbg_readpage(int /*<<< orphan*/, int /*<<< orphan*/ const *);
int /*<<< orphan*/ dump(int /*<<< orphan*/ const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int read_page(const uint8_t *data, uint8_t page) {
  if (0 != dbg_readpage(page, data)) {
    fprintf(stderr, "read_page failed\n");
    return 1;
  }
  printf("data = ");
  dump(data, 1024);
  return 0;
}


x86 assembly (clang, -O0):
<read_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <dbg_readpage@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     118a <read_page+0x4a>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ab <read_page+0x6b>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x400,%esi
call   1040 <dump@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_page>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
mov    %rbx,%rsi
call   1060 <dbg_readpage@plt>
test   %rax,%rax
je     116f <read_page+0x2f>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <dump@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"read_page failed\0A\00"
@.str.1 = [8 x i8] c"data = \00"
define i32 @read_page(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = load i32*, i32** %4
%8 = call i64 @dbg_readpage(i32 %6, i32* %7)
%9 = icmp ne i64 0, %8
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %17
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32*, i32** %4
%16 = call i32 @dump(i32* %15, i32 1024)
store i32 0, i32* %3
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"read_page failed\0A\00"
@.str.1 = [8 x i8] c"data = \00"
define i32 @read_page(i32* %0, i32 %1) {
%3 = tail call i64 @dbg_readpage(i32 %1, i32* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @dump(i32* %0, i32 1024)
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ 1, %5 ], [ 0, %8 ]
ret i32 %12
}