#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*/ assert(int);
size_t GArray_growing_policy(size_t capacity, size_t elem_size) {
  size_t new_capacity = 1;
  assert(elem_size > 0);
  while (new_capacity < capacity && new_capacity > 0)
    new_capacity <<= 1;
  return new_capacity ? new_capacity : capacity;
}


x86 assembly (clang, -O0):
<GArray_growing_policy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jae    1158 <GArray_growing_policy+0x48>
cmpq   $0x0,-0x18(%rbp)
seta   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1168 <GArray_growing_policy+0x58>
jmp    1179 <GArray_growing_policy+0x69>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <GArray_growing_policy+0x2a>
cmpq   $0x0,-0x18(%rbp)
je     1191 <GArray_growing_policy+0x81>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1199 <GArray_growing_policy+0x89>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GArray_growing_policy>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1030 <assert@plt>
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
cmp    %rbx,%rcx
jae    1141 <GArray_growing_policy+0x31>
lea    (%rax,%rax,1),%rcx
test   %rax,%rax
jne    1130 <GArray_growing_policy+0x20>
test   %rax,%rax
cmovne %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @GArray_growing_policy(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 1, i64* %5
%6 = load i64, i64* %4
%7 = icmp ugt i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
br label %10
10: ; preds = %19, %2
%11 = load i64, i64* %5
%12 = load i64, i64* %3
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i64, i64* %5
%16 = icmp ugt i64 %15, 0
br label %17
17: ; preds = %14, %10
%18 = phi i1 [ false, %10 ], [ %16, %14 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i64, i64* %5
%21 = shl i64 %20, 1
store i64 %21, i64* %5
br label %10
22: ; preds = %17
%23 = load i64, i64* %5
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i64, i64* %5
br label %29
27: ; preds = %22
%28 = load i64, i64* %3
br label %29
29: ; preds = %27, %25
%30 = phi i64 [ %26, %25 ], [ %28, %27 ]
ret i64 %30
}

LLVM IR (-O2):
define i64 @GArray_growing_policy(i64 %0, i64 %1) {
%3 = icmp ne i64 %1, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ 1, %2 ], [ %11, %6 ]
%8 = icmp ult i64 %7, %0
%9 = icmp ne i64 %7, 0
%10 = and i1 %8, %9
%11 = shl i64 %7, 1
br i1 %10, label %6, label %12
12: ; preds = %6
%13 = icmp eq i64 %7, 0
%14 = select i1 %13, i64 %0, i64 %7
ret i64 %14
}