#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 */
struct rte_page {
  int dummy;
};

/* Variables and functions */
scalar_t__ PageBuddy(struct rte_page *);
int page_order(struct rte_page *);
scalar_t__ page_zone_id(struct rte_page *);
int page_is_buddy(struct rte_page *page, struct rte_page *buddy, int order) {
  if (page_zone_id(page) != page_zone_id(buddy)) {
    return 0;
  }
  if (PageBuddy(buddy) && (page_order(buddy) == order)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<page_is_buddy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <page_zone_id@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <page_zone_id@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1175 <page_is_buddy+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11ad <page_is_buddy+0x7d>
mov    -0x18(%rbp),%rdi
call   1040 <PageBuddy@plt>
cmp    $0x0,%rax
je     11a6 <page_is_buddy+0x76>
mov    -0x18(%rbp),%rdi
call   1030 <page_order@plt>
cmp    -0x1c(%rbp),%eax
jne    11a6 <page_is_buddy+0x76>
movl   $0x1,-0x4(%rbp)
jmp    11ad <page_is_buddy+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<page_is_buddy>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
call   1050 <page_zone_id@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <page_zone_id@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbp
jne    1177 <page_is_buddy+0x47>
mov    %rbx,%rdi
call   1040 <PageBuddy@plt>
test   %rax,%rax
je     1175 <page_is_buddy+0x45>
mov    %rbx,%rdi
call   1030 <page_order@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %r14d,%ecx
je     1177 <page_is_buddy+0x47>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.rte_page = type { i32 }
define i32 @page_is_buddy(%struct.rte_page* %0, %struct.rte_page* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.rte_page*
%6 = alloca %struct.rte_page*
%7 = alloca i32
store %struct.rte_page* %0, %struct.rte_page** %5
store %struct.rte_page* %1, %struct.rte_page** %6
store i32 %2, i32* %7
%8 = load %struct.rte_page*, %struct.rte_page** %5
%9 = call i64 @page_zone_id(%struct.rte_page* %8)
%10 = load %struct.rte_page*, %struct.rte_page** %6
%11 = call i64 @page_zone_id(%struct.rte_page* %10)
%12 = icmp ne i64 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 0, i32* %4
br label %25
14: ; preds = %3
%15 = load %struct.rte_page*, %struct.rte_page** %6
%16 = call i64 @PageBuddy(%struct.rte_page* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load %struct.rte_page*, %struct.rte_page** %6
%20 = call i32 @page_order(%struct.rte_page* %19)
%21 = load i32, i32* %7
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %4
br label %25
24: ; preds = %18, %14
store i32 0, i32* %4
br label %25
25: ; preds = %24, %23, %13
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
%struct.rte_page = type { i32 }
define i32 @page_is_buddy(%struct.rte_page* %0, %struct.rte_page* %1, i32 %2) {
%4 = tail call i64 @page_zone_id(%struct.rte_page* %0)
%5 = tail call i64 @page_zone_id(%struct.rte_page* %1)
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = tail call i64 @PageBuddy(%struct.rte_page* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @page_order(%struct.rte_page* %1)
%12 = icmp eq i32 %11, %2
br i1 %12, label %14, label %13
13: ; preds = %10, %7
br label %14
14: ; preds = %10, %3, %13
%15 = phi i32 [ 0, %13 ], [ 0, %3 ], [ 1, %10 ]
ret i32 %15
}