#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;
size_t align_to(size_t, size_t);
size_t alignof(int /*<<< orphan*/);
int /*<<< orphan*/ max_align_t;
size_t newcapacity(size_t size, size_t hint) {
  size_t nsize, aligned;
  if (size < (sizeof(double) * 10)) {
    nsize = (hint < (sizeof(double) * 10)) ? (sizeof(double) * 10) : hint;
  } else {
    nsize = size + (size >> 1);
    if (nsize < size) {
      nsize = SIZE_MAX - alignof(max_align_t);
    }
  }
  aligned = align_to(nsize, alignof(max_align_t));
  return aligned < nsize ? 0 : aligned;
}


x86 assembly (clang, -O0):
<newcapacity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x50,-0x8(%rbp)
jae    1169 <newcapacity+0x49>
cmpq   $0x50,-0x10(%rbp)
jae    1154 <newcapacity+0x34>
mov    $0x50,%eax
mov    %rax,-0x28(%rbp)
jmp    115c <newcapacity+0x3c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11b9 <newcapacity+0x99>
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11b4 <newcapacity+0x94>
mov    0x2e3f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1040 <alignof@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    11b9 <newcapacity+0x99>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1040 <alignof@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1030 <align_to@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11f8 <newcapacity+0xd8>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    1200 <newcapacity+0xe0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newcapacity>:
push   %rbx
cmp    $0x4f,%rdi
ja     1136 <newcapacity+0x16>
cmp    $0x51,%rsi
mov    $0x50,%ebx
cmovae %rsi,%rbx
jmp    115c <newcapacity+0x3c>
mov    %rdi,%rbx
shr    %rbx
add    %rdi,%rbx
jae    115c <newcapacity+0x3c>
mov    0x2e88(%rip),%rax
mov    (%rax),%rbx
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
call   1040 <alignof@plt>
sub    %rax,%rbx
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
call   1040 <alignof@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <align_to@plt>
xor    %ecx,%ecx
cmp    %rbx,%rax
cmovb  %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@SIZE_MAX = global i64 0
@max_align_t = global i32 0
define i64 @newcapacity(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = icmp ult i64 %7, 80
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i64, i64* %4
%11 = icmp ult i64 %10, 80
br i1 %11, label %12, label %13
12: ; preds = %9
br label %15
13: ; preds = %9
%14 = load i64, i64* %4
br label %15
15: ; preds = %13, %12
%16 = phi i64 [ 80, %12 ], [ %14, %13 ]
store i64 %16, i64* %5
br label %31
17: ; preds = %2
%18 = load i64, i64* %3
%19 = load i64, i64* %3
%20 = lshr i64 %19, 1
%21 = add i64 %18, %20
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = load i64, i64* %3
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %17
%26 = load i64, i64* @SIZE_MAX
%27 = load i32, i32* @max_align_t
%28 = call i64 @alignof(i32 %27)
%29 = sub i64 %26, %28
store i64 %29, i64* %5
br label %30
30: ; preds = %25, %17
br label %31
31: ; preds = %30, %15
%32 = load i64, i64* %5
%33 = load i32, i32* @max_align_t
%34 = call i64 @alignof(i32 %33)
%35 = call i64 @align_to(i64 %32, i64 %34)
store i64 %35, i64* %6
%36 = load i64, i64* %6
%37 = load i64, i64* %5
%38 = icmp ult i64 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %31
br label %42
40: ; preds = %31
%41 = load i64, i64* %6
br label %42
42: ; preds = %40, %39
%43 = phi i64 [ 0, %39 ], [ %41, %40 ]
ret i64 %43
}

LLVM IR (-O2):
@SIZE_MAX = global i64 0
@max_align_t = global i32 0
define i64 @newcapacity(i64 %0, i64 %1) {
%3 = icmp ult i64 %0, 80
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = icmp ugt i64 %1, 80
%6 = select i1 %5, i64 %1, i64 80
br label %16
7: ; preds = %2
%8 = lshr i64 %0, 1
%9 = add i64 %8, %0
%10 = icmp ult i64 %9, %0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i64, i64* @SIZE_MAX
%13 = load i32, i32* @max_align_t
%14 = tail call i64 @alignof(i32 %13)
%15 = sub i64 %12, %14
br label %16
16: ; preds = %7, %11, %4
%17 = phi i64 [ %6, %4 ], [ %15, %11 ], [ %9, %7 ]
%18 = load i32, i32* @max_align_t
%19 = tail call i64 @alignof(i32 %18)
%20 = tail call i64 @align_to(i64 %17, i64 %19)
%21 = icmp ult i64 %20, %17
%22 = select i1 %21, i64 0, i64 %20
ret i64 %22
}