#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ int8_t;
typedef int int32_t;

/* Variables and functions */
scalar_t__ _bintest(int, int, int, int, int, int, int, int /*<<< orphan*/ *,
                    int, int, int);
float get_dtree_output(int8_t tree[], int r, int c, int sr, int sc, int cost,
                       int sint, uint8_t pixels[], int nrows, int ncols,
                       int ldim) {
  int d, idx;
  int32_t tdepth;
  int32_t *tcodes;
  float *tlut;
  tdepth = *(int32_t *)&tree[0];
  tcodes = (int32_t *)&tree[sizeof(int32_t)];
  tlut = (float *)&tree[(1 + ((1 << tdepth) - 1)) * sizeof(int32_t)];
  idx = 0;
  for (d = 0; d < tdepth; ++d) {
    if (_bintest(tcodes[idx], r, c, sr, sc, cost, sint, pixels, nrows, ncols,
                 ldim))
      idx = 2 * idx + 2;
    else
      idx = 2 * idx + 1;
  }
  return tlut[idx - ((1 << tdepth) - 1)];
}


x86 assembly (clang, -O0):
<get_dtree_output>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %edx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    121c <get_dtree_output+0x10c>
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%r14d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %r14d,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1030 <_bintest@plt>
cmp    $0x0,%rax
je     11fd <get_dtree_output+0xed>
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    1209 <get_dtree_output+0xf9>
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    120e <get_dtree_output+0xfe>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    118b <get_dtree_output+0x7b>
mov    -0x48(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,-0x4c(%rbp)
mov    -0x38(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x4c(%rbp),%ecx
sub    $0x1,%edx
sub    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dtree_output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8d,0x10(%rsp)
mov    %ecx,%r12d
mov    %rdi,%rbx
mov    (%rdi),%r14d
mov    $0x1,%eax
mov    %r14d,%ecx
shl    %cl,%eax
mov    %eax,0xc(%rsp)
test   %r14d,%r14d
jle    11b0 <get_dtree_output+0xa0>
mov    %edx,%r13d
mov    %esi,%ebp
xor    %eax,%eax
jmp    115d <get_dtree_output+0x4d>
nopl   (%rax)
lea    (%r15,%r15,1),%eax
add    $0x2,%eax
add    $0xffffffff,%r14d
je     11b2 <get_dtree_output+0xa2>
movslq %eax,%r15
mov    0x10(%rbx,%r15,4),%edi
sub    $0x8,%rsp
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    0x18(%rsp),%r8d
mov    0x1c(%rsp),%r9d
mov    0x78(%rsp),%eax
push   %rax
mov    0x78(%rsp),%eax
push   %rax
mov    0x78(%rsp),%eax
push   %rax
push   0x78(%rsp)
mov    0x78(%rsp),%eax
push   %rax
call   1030 <_bintest@plt>
add    $0x30,%rsp
test   %rax,%rax
jne    1150 <get_dtree_output+0x40>
lea    (%r15,%r15,1),%eax
add    $0x1,%eax
add    $0xffffffff,%r14d
jne    115d <get_dtree_output+0x4d>
jmp    11b2 <get_dtree_output+0xa2>
xor    %eax,%eax
movslq 0xc(%rsp),%rcx
sub    %ecx,%eax
shl    $0x4,%rcx
add    %rcx,%rbx
add    $0x1,%eax
cltq
movss  (%rbx,%rax,4),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define float @get_dtree_output(i32* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i32 %8, i32 %9, i32 %10) {
%12 = load i32, i32* %0
%13 = getelementptr inbounds i32, i32* %0, i64 4
%14 = shl nuw i32 1, %12
%15 = icmp sgt i32 %12, 0
br i1 %15, label %16, label %30
16: ; preds = %11, %16
%17 = phi i32 [ %28, %16 ], [ 0, %11 ]
%18 = phi i32 [ %27, %16 ], [ 0, %11 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %13, i64 %19
%21 = load i32, i32* %20
%22 = tail call i64 @_bintest(i32 %21, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i32 %8, i32 %9, i32 %10)
%23 = icmp eq i64 %22, 0
%24 = shl nsw i32 %18, 1
%25 = add nsw i32 %24, 2
%26 = or i32 %24, 1
%27 = select i1 %23, i32 %26, i32 %25
%28 = add nuw nsw i32 %17, 1
%29 = icmp eq i32 %28, %12
br i1 %29, label %30, label %16
30: ; preds = %16, %11
%31 = phi i32 [ 0, %11 ], [ %27, %16 ]
%32 = sext i32 %14 to i64
%33 = shl nsw i64 %32, 2
%34 = getelementptr inbounds i32, i32* %0, i64 %33
%35 = sub i32 1, %14
%36 = add i32 %35, %31
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %34, i64 %37
%39 = bitcast i32* %38 to float*
%40 = load float, float* %39
ret float %40
}