#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_buffer(struct bf_ctx *, char *, int);
void nbl_decrypt_headers(struct bf_ctx *pCtx, char *pstrBuffer,
                         int iHeaderChunksPos) {
  int i, iNbChunks;
  iNbChunks = (*((int *)(pstrBuffer + 0x0C)));
  for (i = 0; i < iNbChunks; i++)
    nbl_decrypt_buffer(pCtx, pstrBuffer + iHeaderChunksPos + 0x10 + i * 96,
                       0x30);
}


x86 assembly (clang, -O0):
<nbl_decrypt_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1174 <nbl_decrypt_headers+0x64>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
add    $0x10,%rsi
imul   $0x60,-0x18(%rbp),%eax
cltq
add    %rax,%rsi
mov    $0x30,%edx
call   1030 <nbl_decrypt_buffer@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <nbl_decrypt_headers+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbl_decrypt_headers>:
push   %r15
push   %r14
push   %rbx
mov    0xc(%rsi),%r15d
test   %r15d,%r15d
jle    114a <nbl_decrypt_headers+0x3a>
mov    %rdi,%r14
movslq %edx,%rax
lea    (%rsi,%rax,1),%rbx
add    $0x10,%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x30,%edx
call   1030 <nbl_decrypt_buffer@plt>
add    $0x60,%rbx
add    $0xffffffffffffffff,%r15
jne    1130 <nbl_decrypt_headers+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.bf_ctx = type { i32 }
define void @nbl_decrypt_headers(%struct.bf_ctx* %0, i8* %1, i32 %2) {
%4 = alloca %struct.bf_ctx*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.bf_ctx* %0, %struct.bf_ctx** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 12
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
store i32 %12, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %29, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load %struct.bf_ctx*, %struct.bf_ctx** %4
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = getelementptr inbounds i8, i8* %22, i64 16
%24 = load i32, i32* %7
%25 = mul nsw i32 %24, 96
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = call i32 @nbl_decrypt_buffer(%struct.bf_ctx* %18, i8* %27, i32 48)
br label %29
29: ; preds = %17
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %13
32: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.bf_ctx = type { i32 }
define void @nbl_decrypt_headers(%struct.bf_ctx* %0, i8* %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 12
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 16
%12 = zext i32 %6 to i64
br label %13
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %18, %13 ]
%15 = mul nuw nsw i64 %14, 96
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = tail call i32 @nbl_decrypt_buffer(%struct.bf_ctx* %0, i8* %16, i32 48)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %12
br i1 %19, label %20, label %13
20: ; preds = %13, %3
ret void
}