#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

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

/* Variables and functions */
scalar_t__ FTS_ROOTLEVEL;
void fts_padjust(FTS *sp, void *addr) {
  FTSENT *p;
  for (p = sp->fts_child; p; p = p->fts_link) {
    (p)->fts_accpath = (char *)addr + ((p)->fts_accpath - (p)->fts_path);
    (p)->fts_path = addr;
  };
  for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
    {
      (p)->fts_accpath = (char *)addr + ((p)->fts_accpath - (p)->fts_path);
      (p)->fts_path = addr;
    };
    p = p->fts_link ? p->fts_link : p->fts_parent;
  }
}


x86 assembly (clang, -O0):
<fts_padjust>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1160 <fts_padjust+0x60>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rdx
mov    0x8(%rdx),%rdx
sub    %rdx,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1118 <fts_padjust+0x18>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jl     11e8 <fts_padjust+0xe8>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rdx
mov    0x8(%rdx),%rdx
sub    %rdx,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x20(%rax)
je     11cf <fts_padjust+0xcf>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11db <fts_padjust+0xdb>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    116b <fts_padjust+0x6b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_padjust>:
mov    0x8(%rdi),%rax
test   %rax,%rax
je     112d <fts_padjust+0x2d>
nopl   0x0(%rax)
mov    (%rax),%rcx
mov    0x20(%rax),%rdx
sub    0x8(%rax),%rcx
add    %rsi,%rcx
mov    %rcx,(%rax)
mov    %rsi,0x8(%rax)
mov    %rdx,%rax
test   %rdx,%rdx
jne    1110 <fts_padjust+0x10>
mov    (%rdi),%rcx
mov    0x2eb1(%rip),%rax
mov    (%rax),%rax
cmp    %rax,0x10(%rcx)
jge    1159 <fts_padjust+0x59>
ret
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rcx
cmp    %rax,0x10(%rdx)
jl     1140 <fts_padjust+0x40>
mov    (%rcx),%rdi
mov    0x20(%rcx),%rdx
sub    0x8(%rcx),%rdi
add    %rsi,%rdi
mov    %rdi,(%rcx)
mov    %rsi,0x8(%rcx)
test   %rdx,%rdx
jne    1150 <fts_padjust+0x50>
mov    0x18(%rcx),%rdx
jmp    1150 <fts_padjust+0x50>

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

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