#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int fts_info;
  int /*<<< orphan*/ fts_name;
};
typedef TYPE_1__ FTSENT;

/* Variables and functions */
int FTS_D;
int FTS_DP;
int strcmp(int /*<<< orphan*/, int /*<<< orphan*/);
int compare(const FTSENT **a, const FTSENT **b) {
  int a_is_dir = (*a)->fts_info & (FTS_D | FTS_DP);
  int b_is_dir = (*b)->fts_info & (FTS_D | FTS_DP);
  if (a_is_dir && !b_is_dir)
    return 1;
  if (!a_is_dir && b_is_dir)
    return -1;
  return strcmp((*a)->fts_name, (*b)->fts_name);
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    0x2eb0(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2eaf(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    0x2e90(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e8f(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1180 <compare+0x70>
cmpl   $0x0,-0x20(%rbp)
jne    1180 <compare+0x70>
movl   $0x1,-0x4(%rbp)
jmp    11bc <compare+0xac>
cmpl   $0x0,-0x1c(%rbp)
jne    11a0 <compare+0x90>
cmpl   $0x0,-0x20(%rbp)
je     11a0 <compare+0x90>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bc <compare+0xac>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%esi
call   1030 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
mov    (%rdi),%r8
mov    (%r8),%edi
mov    0x2ec3(%rip),%rax
mov    0x2ec4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    (%rsi),%rdx
mov    (%rdx),%esi
and    %ecx,%esi
test   %edi,%ecx
je     113c <compare+0x2c>
mov    $0x1,%eax
test   %esi,%esi
je     1149 <compare+0x39>
test   %edi,%ecx
jne    114a <compare+0x3a>
mov    $0xffffffff,%eax
test   %esi,%esi
je     114a <compare+0x3a>
ret
mov    0x4(%r8),%edi
mov    0x4(%rdx),%esi
jmp    1030 <strcmp@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i32 }
@FTS_D = global i32 0
@FTS_DP = global i32 0
define i32 @compare(%struct.TYPE_4__** %0, %struct.TYPE_4__** %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_4__**
%5 = alloca %struct.TYPE_4__**
%6 = alloca i32
%7 = alloca i32
store %struct.TYPE_4__** %0, %struct.TYPE_4__*** %4
store %struct.TYPE_4__** %1, %struct.TYPE_4__*** %5
%8 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %4
%9 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @FTS_D
%13 = load i32, i32* @FTS_DP
%14 = or i32 %12, %13
%15 = and i32 %11, %14
store i32 %15, i32* %6
%16 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %5
%17 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* @FTS_D
%21 = load i32, i32* @FTS_DP
%22 = or i32 %20, %21
%23 = and i32 %19, %22
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %26
store i32 1, i32* %3
br label %47
30: ; preds = %26, %2
%31 = load i32, i32* %6
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 -1, i32* %3
br label %47
37: ; preds = %33, %30
%38 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %4
%39 = load %struct.TYPE_4__*, %struct.TYPE_4__** %38
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i32 0, i32 1
%41 = load i32, i32* %40
%42 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %5
%43 = load %struct.TYPE_4__*, %struct.TYPE_4__** %42
%44 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = call i32 @strcmp(i32 %41, i32 %45)
store i32 %46, i32* %3
br label %47
47: ; preds = %37, %36, %29
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i32 }
@FTS_D = global i32 0
@FTS_DP = global i32 0
define i32 @compare(%struct.TYPE_4__** nocapture %0, %struct.TYPE_4__** nocapture %1) {
%3 = load %struct.TYPE_4__*, %struct.TYPE_4__** %0
%4 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = load i32, i32* @FTS_D
%7 = load i32, i32* @FTS_DP
%8 = or i32 %7, %6
%9 = and i32 %8, %5
%10 = load %struct.TYPE_4__*, %struct.TYPE_4__** %1
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i64 0, i32 0
%12 = load i32, i32* %11
%13 = and i32 %12, %8
%14 = icmp eq i32 %9, 0
%15 = icmp ne i32 %13, 0
%16 = select i1 %14, i1 true, i1 %15
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = select i1 %14, i1 %15, i1 false
br i1 %18, label %25, label %19
19: ; preds = %17
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i64 0, i32 1
%23 = load i32, i32* %22
%24 = tail call i32 @strcmp(i32 %21, i32 %23)
br label %25
25: ; preds = %17, %2, %19
%26 = phi i32 [ %24, %19 ], [ 1, %2 ], [ -1, %17 ]
ret i32 %26
}