#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;
};
typedef TYPE_1__ FTSENT;

/* Variables and functions */
int FTS_D;
int FTS_DNR;
int FTS_ERR;
int FTS_NS;
int mastercmp(const FTSENT *const *a, const FTSENT *const *b) {
  int a_info, b_info;
  a_info = (*a)->fts_info;
  if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR)
    return (0);
  b_info = (*b)->fts_info;
  if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR)
    return (0);
  if (a_info == FTS_D)
    return (-1);
  if (b_info == FTS_D)
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<mastercmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2eae(%rip),%rcx
cmp    (%rcx),%eax
je     114e <mastercmp+0x4e>
mov    -0x1c(%rbp),%eax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     114e <mastercmp+0x4e>
mov    -0x1c(%rbp),%eax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
jne    115a <mastercmp+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11eb <mastercmp+0xeb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
je     119c <mastercmp+0x9c>
mov    -0x20(%rbp),%eax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
je     119c <mastercmp+0x9c>
mov    -0x20(%rbp),%eax
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%eax
jne    11a8 <mastercmp+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    11eb <mastercmp+0xeb>
mov    -0x1c(%rbp),%eax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%eax
jne    11c6 <mastercmp+0xc6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11eb <mastercmp+0xeb>
mov    -0x20(%rbp),%eax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
jne    11e4 <mastercmp+0xe4>
movl   $0x1,-0x4(%rbp)
jmp    11eb <mastercmp+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mastercmp>:
mov    (%rdi),%rax
mov    (%rax),%ecx
mov    0x2ec4(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
cmp    %edi,%ecx
je     115e <mastercmp+0x5e>
mov    0x2ea5(%rip),%rdx
mov    (%rdx),%r9d
cmp    %r9d,%ecx
je     115e <mastercmp+0x5e>
mov    0x2ebe(%rip),%rdx
mov    (%rdx),%r8d
cmp    %r8d,%ecx
je     115e <mastercmp+0x5e>
mov    (%rsi),%rdx
mov    (%rdx),%esi
cmp    %edi,%esi
je     115e <mastercmp+0x5e>
cmp    %r9d,%esi
je     115e <mastercmp+0x5e>
cmp    %r8d,%esi
je     115e <mastercmp+0x5e>
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%eax
cmp    %edx,%ecx
je     115e <mastercmp+0x5e>
xor    %eax,%eax
cmp    %edx,%esi
sete   %al
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@FTS_ERR = global i32 0
@FTS_NS = global i32 0
@FTS_DNR = global i32 0
@FTS_D = global i32 0
define i32 @mastercmp(%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
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* @FTS_ERR
%14 = icmp eq i32 %12, %13
br i1 %14, label %23, label %15
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i32, i32* @FTS_NS
%18 = icmp eq i32 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i32, i32* %6
%21 = load i32, i32* @FTS_DNR
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19, %15, %2
store i32 0, i32* %3
br label %52
24: ; preds = %19
%25 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %5
%26 = load %struct.TYPE_4__*, %struct.TYPE_4__** %25
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 0
%28 = load i32, i32* %27
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = load i32, i32* @FTS_ERR
%31 = icmp eq i32 %29, %30
br i1 %31, label %40, label %32
32: ; preds = %24
%33 = load i32, i32* %7
%34 = load i32, i32* @FTS_NS
%35 = icmp eq i32 %33, %34
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i32, i32* %7
%38 = load i32, i32* @FTS_DNR
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %36, %32, %24
store i32 0, i32* %3
br label %52
41: ; preds = %36
%42 = load i32, i32* %6
%43 = load i32, i32* @FTS_D
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 -1, i32* %3
br label %52
46: ; preds = %41
%47 = load i32, i32* %7
%48 = load i32, i32* @FTS_D
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 1, i32* %3
br label %52
51: ; preds = %46
store i32 0, i32* %3
br label %52
52: ; preds = %51, %50, %45, %40, %23
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@FTS_ERR = global i32 0
@FTS_NS = global i32 0
@FTS_DNR = global i32 0
@FTS_D = global i32 0
define i32 @mastercmp(%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_ERR
%7 = icmp eq i32 %5, %6
br i1 %7, label %29, label %8
8: ; preds = %2
%9 = load i32, i32* @FTS_NS
%10 = icmp eq i32 %5, %9
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = load i32, i32* @FTS_DNR
%13 = icmp eq i32 %5, %12
br i1 %13, label %29, label %14
14: ; preds = %11
%15 = load %struct.TYPE_4__*, %struct.TYPE_4__** %1
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i64 0, i32 0
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, %6
%19 = icmp eq i32 %17, %9
%20 = select i1 %18, i1 true, i1 %19
%21 = icmp eq i32 %17, %12
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %29, label %23
23: ; preds = %14
%24 = load i32, i32* @FTS_D
%25 = icmp eq i32 %5, %24
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = icmp eq i32 %17, %24
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %26, %23, %14, %2, %8, %11
%30 = phi i32 [ 0, %11 ], [ 0, %8 ], [ 0, %2 ], [ 0, %14 ], [ -1, %23 ], [ %28, %26 ]
ret i32 %30
}