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

/* Variables and functions */
int GPMODE_R_W_ERROR_PAGE;
int fbo_handle_rwerp_page(uint8_t *buf, size_t buf_len, uint8_t page_control) {
  if (buf_len < 12)
    return -1;
  buf[0] = GPMODE_R_W_ERROR_PAGE;
  buf[1] = 10;
  if (page_control != 1) {
    buf[3] = 5;
    buf[8] = 5;
  }
  return 12;
}


x86 assembly (clang, -O0):
<fbo_handle_rwerp_page>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0xc,-0x18(%rbp)
jae    1126 <fbo_handle_rwerp_page+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    1167 <fbo_handle_rwerp_page+0x67>
mov    0x2ebb(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xa,0x4(%rax)
cmpl   $0x1,-0x1c(%rbp)
je     1160 <fbo_handle_rwerp_page+0x60>
mov    -0x10(%rbp),%rax
movl   $0x5,0xc(%rax)
mov    -0x10(%rbp),%rax
movl   $0x5,0x20(%rax)
movl   $0xc,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fbo_handle_rwerp_page>:
mov    $0xffffffff,%eax
cmp    $0xc,%rsi
jb     1135 <fbo_handle_rwerp_page+0x35>
mov    0x2ed6(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rdi)
movl   $0xa,0x4(%rdi)
mov    $0xc,%eax
cmp    $0x1,%edx
je     1135 <fbo_handle_rwerp_page+0x35>
movl   $0x5,0xc(%rdi)
movl   $0x5,0x20(%rdi)
ret

LLVM IR (-O0):
@GPMODE_R_W_ERROR_PAGE = global i32 0
define i32 @fbo_handle_rwerp_page(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%8 = load i64, i64* %6
%9 = icmp ult i64 %8, 12
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 -1, i32* %4
br label %25
11: ; preds = %3
%12 = load i32, i32* @GPMODE_R_W_ERROR_PAGE
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %12, i32* %14
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 10, i32* %16
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 3
store i32 5, i32* %21
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 8
store i32 5, i32* %23
br label %24
24: ; preds = %19, %11
store i32 12, i32* %4
br label %25
25: ; preds = %24, %10
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@GPMODE_R_W_ERROR_PAGE = global i32 0
define i32 @fbo_handle_rwerp_page(i32* nocapture writeonly %0, i64 %1, i32 %2) {
%4 = icmp ult i64 %1, 12
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = load i32, i32* @GPMODE_R_W_ERROR_PAGE
store i32 %6, i32* %0
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 10, i32* %7
%8 = icmp eq i32 %2, 1
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = getelementptr inbounds i32, i32* %0, i64 3
store i32 5, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 8
store i32 5, i32* %11
br label %12
12: ; preds = %5, %9, %3
%13 = phi i32 [ -1, %3 ], [ 12, %9 ], [ 12, %5 ]
ret i32 %13
}