#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_TO_PROTECT_PAGE;
int fbo_handle_timeout_page(uint8_t *buf, size_t buf_len,
                            uint8_t page_control) {
  if (buf_len < 10)
    return -1;
  buf[0] = GPMODE_TO_PROTECT_PAGE;
  buf[1] = 8;
  if (page_control != 1) {
    buf[6] = 0xff;
    buf[7] = 0xff;
    buf[8] = 0xff;
    buf[9] = 0xff;
  }
  return 10;
}


x86 assembly (clang, -O0):
<fbo_handle_timeout_page>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0xa,-0x18(%rbp)
jae    1126 <fbo_handle_timeout_page+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    117d <fbo_handle_timeout_page+0x7d>
mov    0x2ecb(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x8,0x4(%rax)
cmpl   $0x1,-0x1c(%rbp)
je     1176 <fbo_handle_timeout_page+0x76>
mov    -0x10(%rbp),%rax
movl   $0xff,0x18(%rax)
mov    -0x10(%rbp),%rax
movl   $0xff,0x1c(%rax)
mov    -0x10(%rbp),%rax
movl   $0xff,0x20(%rax)
mov    -0x10(%rbp),%rax
movl   $0xff,0x24(%rax)
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fbo_handle_timeout_page>:
mov    $0xffffffff,%eax
cmp    $0xa,%rsi
jb     1132 <fbo_handle_timeout_page+0x32>
mov    0x2ee6(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rdi)
movl   $0x8,0x4(%rdi)
mov    $0xa,%eax
cmp    $0x1,%edx
je     1132 <fbo_handle_timeout_page+0x32>
movaps 0xed2(%rip),%xmm0
movups %xmm0,0x18(%rdi)
ret

LLVM IR (-O0):
@GPMODE_TO_PROTECT_PAGE = global i32 0
define i32 @fbo_handle_timeout_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, 10
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 -1, i32* %4
br label %29
11: ; preds = %3
%12 = load i32, i32* @GPMODE_TO_PROTECT_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 8, i32* %16
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %11
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 6
store i32 255, i32* %21
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 7
store i32 255, i32* %23
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 8
store i32 255, i32* %25
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 9
store i32 255, i32* %27
br label %28
28: ; preds = %19, %11
store i32 10, i32* %4
br label %29
29: ; preds = %28, %10
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@GPMODE_TO_PROTECT_PAGE = global i32 0
define i32 @fbo_handle_timeout_page(i32* nocapture writeonly %0, i64 %1, i32 %2) {
%4 = icmp ult i64 %1, 10
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = load i32, i32* @GPMODE_TO_PROTECT_PAGE
store i32 %6, i32* %0
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 8, 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 6
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 255, i32 255, i32 255, i32 255>, <4 x i32>* %11
br label %12
12: ; preds = %5, %9, %3
%13 = phi i32 [ -1, %3 ], [ 10, %9 ], [ 10, %5 ]
ret i32 %13
}