#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 */

/* Type definitions */
struct bf_ctx {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ nbl_decrypt_headers(struct bf_ctx *, char *, int);
int nbl_get_tmll_pos(char *);
int /*<<< orphan*/ nbl_has_tmll(char *);
int /*<<< orphan*/ nbl_list_files(char *, int);
int /*<<< orphan*/ printf(char *, int);
void list(unsigned int uOptions, char *pstrBuffer, struct bf_ctx *pCtx) {
  int iTMLLPos;
  if (pCtx)
    nbl_decrypt_headers(pCtx, pstrBuffer, 0x30);
  nbl_list_files(pstrBuffer, 0x30);
  if (!nbl_has_tmll(pstrBuffer))
    return;
  iTMLLPos = nbl_get_tmll_pos(pstrBuffer);
  if (uOptions & 0x4)
    printf("TMLL section found at position 0x%x!\n", iTMLLPos);
  if (pCtx)
    nbl_decrypt_headers(pCtx, pstrBuffer + iTMLLPos, 0x20);
  nbl_list_files(pstrBuffer + iTMLLPos, 0x20);
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1180 <list+0x30>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x30,%edx
call   1060 <nbl_decrypt_headers@plt>
mov    -0x10(%rbp),%rdi
mov    $0x30,%esi
call   1070 <nbl_list_files@plt>
mov    -0x10(%rbp),%rdi
call   1050 <nbl_has_tmll@plt>
cmp    $0x0,%eax
jne    11a5 <list+0x55>
jmp    1208 <list+0xb8>
mov    -0x10(%rbp),%rdi
call   1040 <nbl_get_tmll_pos@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11cf <list+0x7f>
mov    -0x1c(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11f3 <list+0xa3>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    $0x20,%edx
call   1060 <nbl_decrypt_headers@plt>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    $0x20,%esi
call   1070 <nbl_list_files@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
test   %rdx,%rdx
je     1175 <list+0x25>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1060 <nbl_decrypt_headers@plt>
mov    %rbx,%rdi
mov    $0x30,%esi
call   1070 <nbl_list_files@plt>
mov    %rbx,%rdi
call   1050 <nbl_has_tmll@plt>
test   %eax,%eax
je     11df <list+0x8f>
mov    %rbx,%rdi
call   1040 <nbl_get_tmll_pos@plt>
mov    %eax,%ebp
test   $0x4,%r15b
je     11ac <list+0x5c>
lea    0xe5b(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movslq %ebp,%rbp
test   %r14,%r14
je     11c5 <list+0x75>
lea    (%rbx,%rbp,1),%rsi
mov    %r14,%rdi
mov    $0x20,%edx
call   1060 <nbl_decrypt_headers@plt>
add    %rbp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <nbl_list_files@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bf_ctx = type { i32 }
@.str = [38 x i8] c"TMLL section found at position 0x%x!\0A\00"
define void @list(i32 %0, i8* %1, %struct.bf_ctx* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.bf_ctx*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.bf_ctx* %2, %struct.bf_ctx** %6
%8 = load %struct.bf_ctx*, %struct.bf_ctx** %6
%9 = icmp ne %struct.bf_ctx* %8, null
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load %struct.bf_ctx*, %struct.bf_ctx** %6
%12 = load i8*, i8** %5
%13 = call i32 @nbl_decrypt_headers(%struct.bf_ctx* %11, i8* %12, i32 48)
br label %14
14: ; preds = %10, %3
%15 = load i8*, i8** %5
%16 = call i32 @nbl_list_files(i8* %15, i32 48)
%17 = load i8*, i8** %5
%18 = call i32 @nbl_has_tmll(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
br label %46
21: ; preds = %14
%22 = load i8*, i8** %5
%23 = call i32 @nbl_get_tmll_pos(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %4
%25 = and i32 %24, 4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i32, i32* %7
%29 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %21
%31 = load %struct.bf_ctx*, %struct.bf_ctx** %6
%32 = icmp ne %struct.bf_ctx* %31, null
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load %struct.bf_ctx*, %struct.bf_ctx** %6
%35 = load i8*, i8** %5
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = call i32 @nbl_decrypt_headers(%struct.bf_ctx* %34, i8* %38, i32 32)
br label %40
40: ; preds = %33, %30
%41 = load i8*, i8** %5
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = call i32 @nbl_list_files(i8* %44, i32 32)
br label %46
46: ; preds = %40, %20
ret void
}

LLVM IR (-O2):
%struct.bf_ctx = type { i32 }
@.str = [38 x i8] c"TMLL section found at position 0x%x!\0A\00"
define void @list(i32 %0, i8* %1, %struct.bf_ctx* %2) {
%4 = icmp eq %struct.bf_ctx* %2, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @nbl_decrypt_headers(%struct.bf_ctx* %2, i8* %1, i32 48)
br label %7
7: ; preds = %5, %3
%8 = tail call i32 @nbl_list_files(i8* %1, i32 48)
%9 = tail call i32 @nbl_has_tmll(i8* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %7
%12 = tail call i32 @nbl_get_tmll_pos(i8* %1)
%13 = and i32 %0, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %17
17: ; preds = %15, %11
%18 = sext i32 %12 to i64
br i1 %4, label %22, label %19
19: ; preds = %17
%20 = getelementptr inbounds i8, i8* %1, i64 %18
%21 = tail call i32 @nbl_decrypt_headers(%struct.bf_ctx* %2, i8* %20, i32 32)
br label %22
22: ; preds = %17, %19
%23 = getelementptr inbounds i8, i8* %1, i64 %18
%24 = tail call i32 @nbl_list_files(i8* %23, i32 32)
br label %25
25: ; preds = %7, %22
ret void
}