#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 */
size_t SIZE_MAX;
int /*<<< orphan*/ hz_abort(char *, size_t);
size_t hz_vector_next_capacity(size_t current_capacity) {
  if (current_capacity == SIZE_MAX) {
    hz_abort("Cannot resize vector larger than %zu elements", SIZE_MAX);
    return 0;
  } else if (current_capacity > (size_t)(SIZE_MAX / 1.5)) {
    return SIZE_MAX;
  } else {
    size_t scale_capacity = (size_t)(current_capacity * 1.5);
    return (((scale_capacity) > (8)) ? (scale_capacity) : (8));
  }
}


x86 assembly (clang, -O0):
<hz_vector_next_capacity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2eb1(%rip),%rcx
cmp    (%rcx),%rax
jne    1153 <hz_vector_next_capacity+0x43>
mov    0x2ea1(%rip),%rax
mov    (%rax),%rsi
lea    0xeef(%rip),%rdi
call   1030 <hz_abort@plt>
movq   $0x0,-0x8(%rbp)
jmp    125d <hz_vector_next_capacity+0x14d>
mov    -0x10(%rbp),%rax
mov    0x2e7a(%rip),%rcx
movq   (%rcx),%xmm0
movaps 0xe97(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xe9b(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,%rsi
sar    $0x3f,%rsi
movsd  0xe81(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdx
and    %rsi,%rdx
or     %rdx,%rcx
cmp    %rcx,%rax
jbe    11d2 <hz_vector_next_capacity+0xc2>
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    125d <hz_vector_next_capacity+0x14d>
movaps 0xe27(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe26(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xe0c(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x8,-0x18(%rbp)
jbe    1247 <hz_vector_next_capacity+0x137>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1255 <hz_vector_next_capacity+0x145>
mov    $0x8,%eax
mov    %rax,-0x20(%rbp)
jmp    1255 <hz_vector_next_capacity+0x145>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hz_vector_next_capacity>:
push   %rax
mov    %rdi,%rsi
mov    0x2ebd(%rip),%rax
mov    (%rax),%rax
cmp    %rdi,%rax
jne    1133 <hz_vector_next_capacity+0x23>
lea    0xf06(%rip),%rdi
call   1030 <hz_abort@plt>
xor    %eax,%eax
pop    %rcx
ret
movq   %rax,%xmm0
punpckldq 0xec0(%rip),%xmm0
subpd  0xec8(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xec4(%rip),%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,%rdx
subsd  0xebc(%rip),%xmm1
cvttsd2si %xmm1,%rdi
sar    $0x3f,%rdx
and    %rdx,%rdi
or     %rcx,%rdi
cmp    %rsi,%rdi
jb     11d5 <hz_vector_next_capacity+0xc5>
movq   %rsi,%xmm0
punpckldq 0xe73(%rip),%xmm0
subpd  0xe7b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe77(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe6b(%rip),%xmm1
cvttsd2si %xmm1,%rdx
and    %rcx,%rdx
or     %rax,%rdx
cmp    $0x9,%rdx
mov    $0x8,%eax
cmovae %rdx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@SIZE_MAX = global i64 0
@.str = [46 x i8] c"Cannot resize vector larger than %zu elements\00"
define i64 @hz_vector_next_capacity(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = load i64, i64* @SIZE_MAX
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i64, i64* @SIZE_MAX
%10 = call i32 @hz_abort(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 %9)
store i64 0, i64* %2
br label %32
11: ; preds = %1
%12 = load i64, i64* %3
%13 = load i64, i64* @SIZE_MAX
%14 = uitofp i64 %13 to double
%15 = fdiv double %14, 1.500000e+00
%16 = fptoui double %15 to i64
%17 = icmp ugt i64 %12, %16
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = load i64, i64* @SIZE_MAX
store i64 %19, i64* %2
br label %32
20: ; preds = %11
%21 = load i64, i64* %3
%22 = uitofp i64 %21 to double
%23 = fmul double %22, 1.500000e+00
%24 = fptoui double %23 to i64
store i64 %24, i64* %4
%25 = load i64, i64* %4
%26 = icmp ugt i64 %25, 8
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load i64, i64* %4
br label %30
29: ; preds = %20
br label %30
30: ; preds = %29, %27
%31 = phi i64 [ %28, %27 ], [ 8, %29 ]
store i64 %31, i64* %2
br label %32
32: ; preds = %30, %18, %8
%33 = load i64, i64* %2
ret i64 %33
}

LLVM IR (-O2):
@SIZE_MAX = global i64 0
@.str = [46 x i8] c"Cannot resize vector larger than %zu elements\00"
define i64 @hz_vector_next_capacity(i64 %0) {
%2 = load i64, i64* @SIZE_MAX
%3 = icmp eq i64 %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @hz_abort(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %17
6: ; preds = %1
%7 = uitofp i64 %2 to double
%8 = fdiv double %7, 1.500000e+00
%9 = fptoui double %8 to i64
%10 = icmp ult i64 %9, %0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = uitofp i64 %0 to double
%13 = fmul double %12, 1.500000e+00
%14 = fptoui double %13 to i64
%15 = icmp ugt i64 %14, 8
%16 = select i1 %15, i64 %14, i64 8
br label %17
17: ; preds = %6, %11, %4
%18 = phi i64 [ 0, %4 ], [ %16, %11 ], [ %2, %6 ]
ret i64 %18
}