#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 zone {
  int dummy;
};

/* Variables and functions */
int order_base_2(int);
int /*<<< orphan*/ split_page_left(unsigned long, int, int, struct zone *, int);
int /*<<< orphan*/ split_page_right(unsigned long, int, int, struct zone *,
                                    int);
void split_page(unsigned long pfn, unsigned long pfn_split, int order,
                struct zone *z1, struct zone *z2, int migratetype) {
  int l_ct = pfn_split - pfn;
  int l_order = order_base_2(l_ct);
  split_page_left(pfn, l_ct, l_order, z1, migratetype);
  int r_ct = (1 << order) - l_ct;
  int r_order = order - l_order;
  split_page_right(pfn, r_ct, r_order, z2, migratetype);
}


x86 assembly (clang, -O0):
<split_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
sub    -0x8(%rbp),%rax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1030 <order_base_2@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1040 <split_page_left@plt>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <split_page_right@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_page>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8,(%rsp)
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r13
sub    %r13d,%ebx
mov    %ebx,%edi
call   1030 <order_base_2@plt>
mov    %eax,%r14d
mov    %r13,%rdi
mov    %ebx,%esi
mov    %eax,%edx
mov    %r15,%rcx
mov    %r12d,%r8d
call   1040 <split_page_left@plt>
mov    $0x1,%esi
mov    %ebp,%ecx
shl    %cl,%esi
sub    %ebx,%esi
sub    %r14d,%ebp
mov    %r13,%rdi
mov    %ebp,%edx
mov    (%rsp),%rcx
mov    %r12d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <split_page_right@plt>

LLVM IR (-O0):
%struct.zone = type { i32 }
define void @split_page(i64 %0, i64 %1, i32 %2, %struct.zone* %3, %struct.zone* %4, i32 %5) {
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca %struct.zone*
%11 = alloca %struct.zone*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i64 %0, i64* %7
store i64 %1, i64* %8
store i32 %2, i32* %9
store %struct.zone* %3, %struct.zone** %10
store %struct.zone* %4, %struct.zone** %11
store i32 %5, i32* %12
%17 = load i64, i64* %8
%18 = load i64, i64* %7
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %13
%21 = load i32, i32* %13
%22 = call i32 @order_base_2(i32 %21)
store i32 %22, i32* %14
%23 = load i64, i64* %7
%24 = load i32, i32* %13
%25 = load i32, i32* %14
%26 = load %struct.zone*, %struct.zone** %10
%27 = load i32, i32* %12
%28 = call i32 @split_page_left(i64 %23, i32 %24, i32 %25, %struct.zone* %26, i32 %27)
%29 = load i32, i32* %9
%30 = shl i32 1, %29
%31 = load i32, i32* %13
%32 = sub nsw i32 %30, %31
store i32 %32, i32* %15
%33 = load i32, i32* %9
%34 = load i32, i32* %14
%35 = sub nsw i32 %33, %34
store i32 %35, i32* %16
%36 = load i64, i64* %7
%37 = load i32, i32* %15
%38 = load i32, i32* %16
%39 = load %struct.zone*, %struct.zone** %11
%40 = load i32, i32* %12
%41 = call i32 @split_page_right(i64 %36, i32 %37, i32 %38, %struct.zone* %39, i32 %40)
ret void
}

LLVM IR (-O2):
%struct.zone = type { i32 }
define void @split_page(i64 %0, i64 %1, i32 %2, %struct.zone* %3, %struct.zone* %4, i32 %5) {
%7 = sub i64 %1, %0
%8 = trunc i64 %7 to i32
%9 = tail call i32 @order_base_2(i32 %8)
%10 = tail call i32 @split_page_left(i64 %0, i32 %8, i32 %9, %struct.zone* %3, i32 %5)
%11 = shl nuw i32 1, %2
%12 = sub nsw i32 %11, %8
%13 = sub nsw i32 %2, %9
%14 = tail call i32 @split_page_right(i64 %0, i32 %12, i32 %13, %struct.zone* %4, i32 %5)
ret void
}