#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__ {
  scalar_t__ fts_pathlen;
  char *fts_path;
};
typedef TYPE_1__ FTS;

/* Variables and functions */
int /*<<< orphan*/ ENAMETOOLONG;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
char *realloc(char *, scalar_t__);
int fts_palloc(FTS *sp, size_t more) {
  char *p;
  more += 256;
  if (sp->fts_pathlen + more < sp->fts_pathlen) {
    if (sp->fts_path)
      free(sp->fts_path);
    sp->fts_path = NULL;
    errno = ENAMETOOLONG;
    return (1);
  }
  sp->fts_pathlen += more;
  p = realloc(sp->fts_path, sp->fts_pathlen);
  if (p == NULL) {
    if (sp->fts_path)
      free(sp->fts_path);
    sp->fts_path = NULL;
    return (1);
  }
  sp->fts_path = p;
  return (0);
}


x86 assembly (clang, -O0):
<fts_palloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
add    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jae    119c <fts_palloc+0x7c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1172 <fts_palloc+0x52>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    0x2e53(%rip),%rax
mov    (%rax),%ecx
mov    0x2e52(%rip),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1214 <fts_palloc+0xf4>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1201 <fts_palloc+0xe1>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11e9 <fts_palloc+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1214 <fts_palloc+0xf4>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_palloc>:
push   %rbx
mov    %rdi,%rbx
add    $0x100,%rsi
add    (%rdi),%rsi
jae    115a <fts_palloc+0x3a>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     113e <fts_palloc+0x1e>
call   1030 <free@plt>
movq   $0x0,0x8(%rbx)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    0x2e8a(%rip),%rcx
mov    %eax,(%rcx)
jmp    1189 <fts_palloc+0x69>
mov    %rsi,(%rbx)
mov    0x8(%rbx),%rdi
call   1040 <realloc@plt>
test   %rax,%rax
je     1173 <fts_palloc+0x53>
mov    %rax,0x8(%rbx)
xor    %eax,%eax
pop    %rbx
ret
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1181 <fts_palloc+0x61>
call   1030 <free@plt>
movq   $0x0,0x8(%rbx)
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i8* }
@ENAMETOOLONG = global i32 0
@errno = global i32 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 = add i64 %7, 256
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 i64, i64* %10
%12 = load i64, i64* %5
%13 = add i64 %11, %12
%14 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = icmp ult i64 %13, %16
br i1 %17, label %18, label %32
18: ; preds = %2
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 1
%26 = load i8*, i8** %25
%27 = call i32 @free(i8* %26)
br label %28
28: ; preds = %23, %18
%29 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 1
store i8* null, i8** %30
%31 = load i32, i32* @ENAMETOOLONG
store i32 %31, i32* @errno
store i32 1, i32* %3
br label %64
32: ; preds = %2
%33 = load i64, i64* %5
%34 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
%36 = load i64, i64* %35
%37 = add i64 %36, %33
store i64 %37, i64* %35
%38 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %38, i32 0, i32 1
%40 = load i8*, i8** %39
%41 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %41, i32 0, i32 0
%43 = load i64, i64* %42
%44 = call i8* @realloc(i8* %40, i64 %43)
store i8* %44, i8** %6
%45 = load i8*, i8** %6
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %60
47: ; preds = %32
%48 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%49 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %48, i32 0, i32 1
%50 = load i8*, i8** %49
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %57
52: ; preds = %47
%53 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%54 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %53, i32 0, i32 1
%55 = load i8*, i8** %54
%56 = call i32 @free(i8* %55)
br label %57
57: ; preds = %52, %47
%58 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 1
store i8* null, i8** %59
store i32 1, i32* %3
br label %64
60: ; preds = %32
%61 = load i8*, i8** %6
%62 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%63 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %62, i32 0, i32 1
store i8* %61, i8** %63
store i32 0, i32* %3
br label %64
64: ; preds = %60, %57, %28
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i8* }
@ENAMETOOLONG = global i32 0
@errno = global i32 0
define i32 @fts_palloc(%struct.TYPE_3__* nocapture %0, i64 %1) {
%3 = add i64 %1, 256
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = add i64 %3, %5
%7 = icmp ult i64 %6, %5
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @free(i8* %10)
br label %14
14: ; preds = %12, %8
store i8* null, i8** %9
%15 = load i32, i32* @ENAMETOOLONG
store i32 %15, i32* @errno
br label %28
16: ; preds = %2
store i64 %6, i64* %4
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%18 = load i8*, i8** %17
%19 = tail call i8* @realloc(i8* %18, i64 %6)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load i8*, i8** %17
%23 = icmp eq i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @free(i8* %22)
br label %26
26: ; preds = %24, %21
store i8* null, i8** %17
br label %28
27: ; preds = %16
store i8* %19, i8** %17
br label %28
28: ; preds = %27, %26, %14
%29 = phi i32 [ 1, %14 ], [ 1, %26 ], [ 0, %27 ]
ret i32 %29
}