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

/* Variables and functions */
int /*<<< orphan*/ add_free_page_to_zone(unsigned int, unsigned int);
int clz(unsigned int);
void add_memory_to_pool(unsigned page_offset, unsigned page_cnt) {
  ;
  while (page_cnt) {
    unsigned biggest_page_order = (63 - clz(page_cnt));
    add_free_page_to_zone(page_offset, biggest_page_order);
    page_offset += 1 << biggest_page_order;
    page_cnt -= 1 << biggest_page_order;
  }
}


x86 assembly (clang, -O0):
<add_memory_to_pool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1180 <add_memory_to_pool+0x60>
mov    -0x8(%rbp),%edi
call   1030 <clz@plt>
mov    %eax,%ecx
mov    $0x3f,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <add_free_page_to_zone@plt>
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    112e <add_memory_to_pool+0xe>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_memory_to_pool>:
push   %rbp
push   %r14
push   %rbx
test   %esi,%esi
je     1158 <add_memory_to_pool+0x38>
mov    %esi,%r14d
mov    %edi,%ebp
nopl   (%rax)
mov    %r14d,%edi
call   1030 <clz@plt>
mov    $0x3f,%ebx
sub    %eax,%ebx
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <add_free_page_to_zone@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
add    %eax,%ebp
sub    %eax,%r14d
jne    1130 <add_memory_to_pool+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @add_memory_to_pool(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %6
6: ; preds = %9, %2
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 @clz(i32 %10)
%12 = sub nsw i32 63, %11
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = load i32, i32* %5
%15 = call i32 @add_free_page_to_zone(i32 %13, i32 %14)
%16 = load i32, i32* %5
%17 = shl i32 1, %16
%18 = load i32, i32* %3
%19 = add i32 %18, %17
store i32 %19, i32* %3
%20 = load i32, i32* %5
%21 = shl i32 1, %20
%22 = load i32, i32* %4
%23 = sub i32 %22, %21
store i32 %23, i32* %4
br label %6
24: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @add_memory_to_pool(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %11, %4 ], [ %0, %2 ]
%6 = phi i32 [ %12, %4 ], [ %1, %2 ]
%7 = tail call i32 @clz(i32 %6)
%8 = sub nsw i32 63, %7
%9 = tail call i32 @add_free_page_to_zone(i32 %5, i32 %8)
%10 = shl nuw i32 1, %8
%11 = add i32 %10, %5
%12 = sub i32 %6, %10
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %4
14: ; preds = %4, %2
ret void
}