#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__ {
  int fts_info;
  TYPE_1__ *fts_statp;
};
struct TYPE_5__ {
  int /*<<< orphan*/ st_mode;
};
typedef TYPE_2__ FTSENT;

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int fts_dirsfirst(const FTSENT **a, const FTSENT **b) {
  assert(a != NULL);
  assert((*a) != NULL);
  assert(b != NULL);
  assert((*b) != NULL);
  if (((*a)->fts_info == 10) || ((*a)->fts_info == 11) ||
      ((*b)->fts_info == 10) || ((*b)->fts_info == 11))
    return (0);
  if (S_ISDIR((*a)->fts_statp->st_mode))
    if (!S_ISDIR((*b)->fts_statp->st_mode))
      return (-1);
    else
      return (0);
  else if (S_ISDIR((*b)->fts_statp->st_mode))
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<fts_dirsfirst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpl   $0xa,(%rax)
je     11be <fts_dirsfirst+0x9e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpl   $0xb,(%rax)
je     11be <fts_dirsfirst+0x9e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmpl   $0xa,(%rax)
je     11be <fts_dirsfirst+0x9e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmpl   $0xb,(%rax)
jne    11ca <fts_dirsfirst+0xaa>
movl   $0x0,-0x4(%rbp)
jmp    1249 <fts_dirsfirst+0x129>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
cmp    $0x0,%rax
je     121a <fts_dirsfirst+0xfa>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    120e <fts_dirsfirst+0xee>
movl   $0xffffffff,-0x4(%rbp)
jmp    1249 <fts_dirsfirst+0x129>
movl   $0x0,-0x4(%rbp)
jmp    1249 <fts_dirsfirst+0x129>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1242 <fts_dirsfirst+0x122>
movl   $0x1,-0x4(%rbp)
jmp    1249 <fts_dirsfirst+0x129>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_dirsfirst>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%r14)
setne  %dil
call   1040 <assert@plt>
mov    (%rbx),%rcx
mov    (%rcx),%edx
and    $0xfffffffe,%edx
xor    %eax,%eax
cmp    $0xa,%edx
je     11b4 <fts_dirsfirst+0x94>
mov    (%r14),%rdx
mov    (%rdx),%edx
and    $0xfffffffe,%edx
cmp    $0xa,%edx
je     11b4 <fts_dirsfirst+0x94>
mov    0x8(%rcx),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
mov    %rax,%rbx
mov    (%r14),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   1030 <S_ISDIR@plt>
mov    %rax,%rcx
test   %rbx,%rbx
je     11ac <fts_dirsfirst+0x8c>
cmp    $0x1,%rcx
sbb    %eax,%eax
jmp    11b4 <fts_dirsfirst+0x94>
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32 }
define i32 @fts_dirsfirst(%struct.TYPE_6__** %0, %struct.TYPE_6__** %1) {
%3 = icmp ne %struct.TYPE_6__** %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = load %struct.TYPE_6__*, %struct.TYPE_6__** %0
%7 = icmp ne %struct.TYPE_6__* %6, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne %struct.TYPE_6__** %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = load %struct.TYPE_6__*, %struct.TYPE_6__** %1
%14 = icmp ne %struct.TYPE_6__* %13, null
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = load %struct.TYPE_6__*, %struct.TYPE_6__** %0
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %17, i64 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, -2
%21 = icmp eq i32 %20, 10
br i1 %21, label %47, label %22
22: ; preds = %2
%23 = load %struct.TYPE_6__*, %struct.TYPE_6__** %1
%24 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %23, i64 0, i32 0
%25 = load i32, i32* %24
%26 = and i32 %25, -2
%27 = icmp eq i32 %26, 10
br i1 %27, label %47, label %28
28: ; preds = %22
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %17, i64 0, i32 1
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %29
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i64 @S_ISDIR(i32 %32)
%34 = icmp eq i64 %33, 0
%35 = load %struct.TYPE_6__*, %struct.TYPE_6__** %1
%36 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %35, i64 0, i32 1
%37 = load %struct.TYPE_5__*, %struct.TYPE_5__** %36
%38 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %37, i64 0, i32 0
%39 = load i32, i32* %38
%40 = tail call i64 @S_ISDIR(i32 %39)
br i1 %34, label %44, label %41
41: ; preds = %28
%42 = icmp eq i64 %40, 0
%43 = sext i1 %42 to i32
br label %47
44: ; preds = %28
%45 = icmp ne i64 %40, 0
%46 = zext i1 %45 to i32
br label %47
47: ; preds = %22, %2, %44, %41
%48 = phi i32 [ 0, %22 ], [ 0, %2 ], [ %43, %41 ], [ %46, %44 ]
ret i32 %48
}