#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  char *fts_path;
  size_t fts_pathlen;
};
typedef TYPE_1__ FTS;

/* Variables and functions */
size_t UINT_MAX;
size_t fts_pow2(size_t);
char *realloc(char *, size_t);
int fts_palloc(FTS *sp, size_t size) {
  char *new;
  ;
  size = fts_pow2(size);
  new = realloc(sp->fts_path, size);
  if (new == 0)
    return (1);
  sp->fts_path = new;
  sp->fts_pathlen = ((size) > UINT_MAX ? UINT_MAX : (unsigned int)(size));
  return (0);
}


x86 assembly (clang, -O0):
<fts_palloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fts_pow2@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1168 <fts_palloc+0x48>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <fts_palloc+0x97>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
jbe    119a <fts_palloc+0x7a>
mov    0x2e5a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11a4 <fts_palloc+0x84>
mov    -0x18(%rbp),%rax
mov    %eax,%eax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_palloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <fts_pow2@plt>
mov    %rax,%rbx
mov    (%r14),%rdi
mov    %rax,%rsi
call   1040 <realloc@plt>
test   %rax,%rax
je     1160 <fts_palloc+0x40>
mov    %rax,(%r14)
mov    0x2e9c(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%rbx
mov    %ebx,%ecx
cmova  %rax,%rcx
mov    %rcx,0x8(%r14)
xor    %eax,%eax
jmp    1165 <fts_palloc+0x45>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i64 }
@UINT_MAX = global i64 0
define i32 @fts_palloc(%struct.TYPE_3__* %0, i64 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i64
%6 = alloca i8*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = call i64 @fts_pow2(i64 %7)
store i64 %8, i64* %5
%9 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = load i64, i64* %5
%13 = call i8* @realloc(i8* %11, i64 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %34
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
store i8* %18, i8** %20
%21 = load i64, i64* %5
%22 = load i64, i64* @UINT_MAX
%23 = icmp ugt i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = load i64, i64* @UINT_MAX
br label %30
26: ; preds = %17
%27 = load i64, i64* %5
%28 = trunc i64 %27 to i32
%29 = zext i32 %28 to i64
br label %30
30: ; preds = %26, %24
%31 = phi i64 [ %25, %24 ], [ %29, %26 ]
%32 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %32, i32 0, i32 1
store i64 %31, i64* %33
store i32 0, i32* %3
br label %34
34: ; preds = %30, %16
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i64 }
@UINT_MAX = global i64 0
define i32 @fts_palloc(%struct.TYPE_3__* nocapture %0, i64 %1) {
%3 = tail call i64 @fts_pow2(i64 %1)
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = tail call i8* @realloc(i8* %5, i64 %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %2
store i8* %6, i8** %4
%9 = load i64, i64* @UINT_MAX
%10 = icmp ugt i64 %3, %9
%11 = and i64 %3, 4294967295
%12 = select i1 %10, i64 %9, i64 %11
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
store i64 %12, i64* %13
br label %14
14: ; preds = %2, %8
%15 = phi i32 [ 0, %8 ], [ 1, %2 ]
ret i32 %15
}