#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  char *fts_path;
  TYPE_1__ *fts_child;
};
struct TYPE_5__ {
  char *fts_accpath;
  char *fts_name;
  char *fts_path;
  scalar_t__ fts_level;
  struct TYPE_5__ *fts_parent;
  struct TYPE_5__ *fts_link;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
scalar_t__ FTS_ROOTLEVEL;
int /*<<< orphan*/ _DIAGASSERT(int /*<<< orphan*/);
void fts_padjust(FTS *sp, FTSENT *head) {
  FTSENT *p;
  char *addr;
  _DIAGASSERT(sp != NULL);
  addr = sp->fts_path;
  for (p = sp->fts_child; p; p = p->fts_link)
    do {
      if ((p)->fts_accpath != (p)->fts_name)
        (p)->fts_accpath = addr + ((p)->fts_accpath - (p)->fts_path);
      (p)->fts_path = addr;
    } while (0);
  for (p = head; p->fts_level >= FTS_ROOTLEVEL;) {
    do {
      if ((p)->fts_accpath != (p)->fts_name)
        (p)->fts_accpath = addr + ((p)->fts_accpath - (p)->fts_path);
      (p)->fts_path = addr;
    } while (0);
    p = p->fts_link ? p->fts_link : p->fts_parent;
  }
}


x86 assembly (clang, -O0):
<fts_padjust>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <_DIAGASSERT@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b0 <fts_padjust+0xa0>
jmp    1159 <fts_padjust+0x49>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
je     118e <fts_padjust+0x7e>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rdx
mov    0x10(%rdx),%rdx
sub    %rdx,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
jmp    119f <fts_padjust+0x8f>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1149 <fts_padjust+0x39>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%rax
jl     124f <fts_padjust+0x13f>
jmp    11d5 <fts_padjust+0xc5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    0x8(%rcx),%rax
je     120a <fts_padjust+0xfa>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rdx
mov    0x10(%rdx),%rdx
sub    %rdx,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x28(%rax)
je     1236 <fts_padjust+0x126>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1242 <fts_padjust+0x132>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11b8 <fts_padjust+0xa8>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_padjust>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <_DIAGASSERT@plt>
mov    (%r14),%rax
mov    0x8(%r14),%rcx
jmp    1148 <fts_padjust+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,0x10(%rcx)
mov    0x28(%rcx),%rcx
test   %rcx,%rcx
je     1162 <fts_padjust+0x52>
mov    (%rcx),%rdx
cmp    0x8(%rcx),%rdx
je     1140 <fts_padjust+0x30>
sub    0x10(%rcx),%rdx
add    %rax,%rdx
mov    %rdx,(%rcx)
jmp    1140 <fts_padjust+0x30>
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%rcx
cmp    %rcx,0x18(%rbx)
jge    1189 <fts_padjust+0x79>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
nopw   0x0(%rax,%rax,1)
mov    %rdx,%rbx
cmp    %rcx,0x18(%rdx)
jl     1172 <fts_padjust+0x62>
mov    (%rbx),%rdx
cmp    0x8(%rbx),%rdx
je     119c <fts_padjust+0x8c>
sub    0x10(%rbx),%rdx
add    %rax,%rdx
mov    %rdx,(%rbx)
mov    %rax,0x10(%rbx)
mov    0x28(%rbx),%rdx
test   %rdx,%rdx
jne    1180 <fts_padjust+0x70>
mov    0x20(%rbx),%rdx
jmp    1180 <fts_padjust+0x70>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i8*, %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i8*, i8*, i64, %struct.TYPE_5__*, %struct.TYPE_5__* }
@FTS_ROOTLEVEL = global i64 0
define void @fts_padjust(%struct.TYPE_6__* %0, %struct.TYPE_5__* %1) {
%3 = alloca %struct.TYPE_6__*
%4 = alloca %struct.TYPE_5__*
%5 = alloca %struct.TYPE_5__*
%6 = alloca i8*
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %3
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %4
%7 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%8 = icmp ne %struct.TYPE_6__* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @_DIAGASSERT(i32 %9)
%11 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%12 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %11, i32 0, i32 0
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %14, i32 0, i32 1
%16 = load %struct.TYPE_5__*, %struct.TYPE_5__** %15
store %struct.TYPE_5__* %16, %struct.TYPE_5__** %5
br label %17
17: ; preds = %48, %2
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%19 = icmp ne %struct.TYPE_5__* %18, null
br i1 %19, label %20, label %52
20: ; preds = %17
br label %21
21: ; preds = %20
%22 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %25, i32 0, i32 1
%27 = load i8*, i8** %26
%28 = icmp ne i8* %24, %27
br i1 %28, label %29, label %43
29: ; preds = %21
%30 = load i8*, i8** %6
%31 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %31, i32 0, i32 0
%33 = load i8*, i8** %32
%34 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i32 0, i32 2
%36 = load i8*, i8** %35
%37 = ptrtoint i8* %33 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
%40 = getelementptr inbounds i8, i8* %30, i64 %39
%41 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%42 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %41, i32 0, i32 0
store i8* %40, i8** %42
br label %43
43: ; preds = %29, %21
%44 = load i8*, i8** %6
%45 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%46 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %45, i32 0, i32 2
store i8* %44, i8** %46
br label %47
47: ; preds = %43
br label %48
48: ; preds = %47
%49 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %49, i32 0, i32 5
%51 = load %struct.TYPE_5__*, %struct.TYPE_5__** %50
store %struct.TYPE_5__* %51, %struct.TYPE_5__** %5
br label %17
52: ; preds = %17
%53 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
store %struct.TYPE_5__* %53, %struct.TYPE_5__** %5
br label %54
54: ; preds = %100, %52
%55 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%56 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %55, i32 0, i32 3
%57 = load i64, i64* %56
%58 = load i64, i64* @FTS_ROOTLEVEL
%59 = icmp sge i64 %57, %58
br i1 %59, label %60, label %102
60: ; preds = %54
br label %61
61: ; preds = %60
%62 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%63 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %62, i32 0, i32 0
%64 = load i8*, i8** %63
%65 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%66 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %65, i32 0, i32 1
%67 = load i8*, i8** %66
%68 = icmp ne i8* %64, %67
br i1 %68, label %69, label %83
69: ; preds = %61
%70 = load i8*, i8** %6
%71 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%72 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%75 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %74, i32 0, i32 2
%76 = load i8*, i8** %75
%77 = ptrtoint i8* %73 to i64
%78 = ptrtoint i8* %76 to i64
%79 = sub i64 %77, %78
%80 = getelementptr inbounds i8, i8* %70, i64 %79
%81 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %81, i32 0, i32 0
store i8* %80, i8** %82
br label %83
83: ; preds = %69, %61
%84 = load i8*, i8** %6
%85 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%86 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %85, i32 0, i32 2
store i8* %84, i8** %86
br label %87
87: ; preds = %83
%88 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%89 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %88, i32 0, i32 5
%90 = load %struct.TYPE_5__*, %struct.TYPE_5__** %89
%91 = icmp ne %struct.TYPE_5__* %90, null
br i1 %91, label %92, label %96
92: ; preds = %87
%93 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%94 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %93, i32 0, i32 5
%95 = load %struct.TYPE_5__*, %struct.TYPE_5__** %94
br label %100
96: ; preds = %87
%97 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%98 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %97, i32 0, i32 4
%99 = load %struct.TYPE_5__*, %struct.TYPE_5__** %98
br label %100
100: ; preds = %96, %92
%101 = phi %struct.TYPE_5__* [ %95, %92 ], [ %99, %96 ]
store %struct.TYPE_5__* %101, %struct.TYPE_5__** %5
br label %54
102: ; preds = %54
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i8*, %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i8*, i8*, i64, %struct.TYPE_5__*, %struct.TYPE_5__* }
@FTS_ROOTLEVEL = global i64 0
define void @fts_padjust(%struct.TYPE_6__* %0, %struct.TYPE_5__* nocapture %1) {
%3 = icmp ne %struct.TYPE_6__* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @_DIAGASSERT(i32 %4)
%6 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%10 = icmp eq %struct.TYPE_5__* %9, null
br i1 %10, label %11, label %16
11: ; preds = %30, %2
%12 = load i64, i64* @FTS_ROOTLEVEL
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
%14 = load i64, i64* %13
%15 = icmp slt i64 %14, %12
br i1 %15, label %62, label %35
16: ; preds = %2, %30
%17 = phi %struct.TYPE_5__* [ %33, %30 ], [ %9, %2 ]
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 0, i32 0
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 0, i32 1
%21 = load i8*, i8** %20
%22 = icmp eq i8* %19, %21
br i1 %22, label %30, label %23
23: ; preds = %16
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 0, i32 2
%25 = load i8*, i8** %24
%26 = ptrtoint i8* %19 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = getelementptr inbounds i8, i8* %7, i64 %28
store i8* %29, i8** %18
br label %30
30: ; preds = %23, %16
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 0, i32 2
store i8* %7, i8** %31
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 0, i32 5
%33 = load %struct.TYPE_5__*, %struct.TYPE_5__** %32
%34 = icmp eq %struct.TYPE_5__* %33, null
br i1 %34, label %11, label %16
35: ; preds = %11, %57
%36 = phi %struct.TYPE_5__* [ %58, %57 ], [ %1, %11 ]
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 0
%38 = load i8*, i8** %37
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 1
%40 = load i8*, i8** %39
%41 = icmp eq i8* %38, %40
br i1 %41, label %49, label %42
42: ; preds = %35
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 2
%44 = load i8*, i8** %43
%45 = ptrtoint i8* %38 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = getelementptr inbounds i8, i8* %7, i64 %47
store i8* %48, i8** %37
br label %49
49: ; preds = %42, %35
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 2
store i8* %7, i8** %50
%51 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 5
%52 = load %struct.TYPE_5__*, %struct.TYPE_5__** %51
%53 = icmp eq %struct.TYPE_5__* %52, null
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 0, i32 4
%56 = load %struct.TYPE_5__*, %struct.TYPE_5__** %55
br label %57
57: ; preds = %49, %54
%58 = phi %struct.TYPE_5__* [ %56, %54 ], [ %52, %49 ]
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %58, i64 0, i32 3
%60 = load i64, i64* %59
%61 = icmp slt i64 %60, %12
br i1 %61, label %62, label %35
62: ; preds = %57, %11
ret void
}