#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;
int /*<<< orphan*/ _DIAGASSERT(int /*<<< orphan*/);
size_t fts_pow2(size_t);
char *realloc(char *, size_t);
int fts_palloc(FTS *sp, size_t size) {
  char *new;
  _DIAGASSERT(sp != NULL);
  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)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <_DIAGASSERT@plt>
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   1050 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118a <fts_palloc+0x5a>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <fts_palloc+0xa9>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%rax
jbe    11bc <fts_palloc+0x8c>
mov    0x2e38(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11c6 <fts_palloc+0x96>
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    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <_DIAGASSERT@plt>
mov    %rbx,%rdi
call   1030 <fts_pow2@plt>
mov    %rax,%rbx
mov    (%r14),%rdi
mov    %rax,%rsi
call   1050 <realloc@plt>
test   %rax,%rax
je     1181 <fts_palloc+0x51>
mov    %rax,(%r14)
mov    0x2e7b(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%rbx
mov    %ebx,%ecx
cmova  %rax,%rcx
mov    %rcx,0x8(%r14)
xor    %eax,%eax
jmp    1186 <fts_palloc+0x56>
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 %struct.TYPE_3__*, %struct.TYPE_3__** %4
%8 = icmp ne %struct.TYPE_3__* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @_DIAGASSERT(i32 %9)
%11 = load i64, i64* %5
%12 = call i64 @fts_pow2(i64 %11)
store i64 %12, i64* %5
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = load i64, i64* %5
%17 = call i8* @realloc(i8* %15, i64 %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 1, i32* %3
br label %38
21: ; preds = %2
%22 = load i8*, i8** %6
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
store i8* %22, i8** %24
%25 = load i64, i64* %5
%26 = load i64, i64* @UINT_MAX
%27 = icmp ugt i64 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = load i64, i64* @UINT_MAX
br label %34
30: ; preds = %21
%31 = load i64, i64* %5
%32 = trunc i64 %31 to i32
%33 = zext i32 %32 to i64
br label %34
34: ; preds = %30, %28
%35 = phi i64 [ %29, %28 ], [ %33, %30 ]
%36 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %36, i32 0, i32 1
store i64 %35, i64* %37
store i32 0, i32* %3
br label %38
38: ; preds = %34, %20
%39 = load i32, i32* %3
ret i32 %39
}

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