#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 vec_reserve_(char **, int *, int *, int, int);
int vec_reserve_po2_(char **data, int *length, int *capacity, int memsz,
                     int n) {
  int n2 = 1;
  if (n == 0)
    return 0;
  while (n2 < n)
    n2 <<= 1;
  return vec_reserve_(data, length, capacity, memsz, n2);
}


x86 assembly (clang, -O0):
<vec_reserve_po2_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1148 <vec_reserve_po2_+0x38>
movl   $0x0,-0x4(%rbp)
jmp    1182 <vec_reserve_po2_+0x72>
jmp    114d <vec_reserve_po2_+0x3d>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1167 <vec_reserve_po2_+0x57>
mov    -0x2c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114d <vec_reserve_po2_+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1030 <vec_reserve_@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec_reserve_po2_>:
test   %r8d,%r8d
je     1134 <vec_reserve_po2_+0x24>
mov    $0x1,%r9d
nopl   0x0(%rax,%rax,1)
mov    %r9d,%eax
lea    (%rax,%rax,1),%r9d
cmp    %r8d,%eax
jl     1120 <vec_reserve_po2_+0x10>
mov    %eax,%r8d
jmp    1030 <vec_reserve_@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @vec_reserve_po2_(i8** %0, i32* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 1, i32* %12
%13 = load i32, i32* %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %5
store i32 0, i32* %6
br label %31
16: ; preds = %5
br label %17
17: ; preds = %21, %16
%18 = load i32, i32* %12
%19 = load i32, i32* %11
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %12
%23 = shl i32 %22, 1
store i32 %23, i32* %12
br label %17
24: ; preds = %17
%25 = load i8**, i8*** %7
%26 = load i32*, i32** %8
%27 = load i32*, i32** %9
%28 = load i32, i32* %10
%29 = load i32, i32* %12
%30 = call i32 @vec_reserve_(i8** %25, i32* %26, i32* %27, i32 %28, i32 %29)
store i32 %30, i32* %6
br label %31
31: ; preds = %24, %15
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
define i32 @vec_reserve_po2_(i8** %0, i32* %1, i32* %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %13, label %7
7: ; preds = %5, %7
%8 = phi i32 [ %10, %7 ], [ 1, %5 ]
%9 = icmp slt i32 %8, %4
%10 = shl i32 %8, 1
br i1 %9, label %7, label %11
11: ; preds = %7
%12 = tail call i32 @vec_reserve_(i8** %0, i32* %1, i32* %2, i32 %3, i32 %8)
br label %13
13: ; preds = %5, %11
%14 = phi i32 [ %12, %11 ], [ 0, %5 ]
ret i32 %14
}