// File: /workspace/github_c_makefile_star2_O0/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: ct_init()
void ct_init() {
    int n;        /* iterates over tree elements */
    int bits;     /* bit counter */
    int length;   /* length value */
    int code;     /* code value */
    int dist;     /* distance index */
        
    if (static_dtree[0].Len != 0) return; /* ct_init already called */

    /* Initialize the mapping length (0..255) -> length code (0..28) */
    length = 0;
    for (code = 0; code < LENGTH_CODES-1; code++) {
        base_length[code] = length;
        for (n = 0; n < (1<<extra_lbits[code]); n++) {
            length_code[length++] = (u8)code;
        }
    }
    // Assert (length == 256, "ct_init: length != 256");
    /* Note that the length 255 (match length 258) can be represented
     * in two different ways: code 284 + 5 bits or code 285, so we
     * overwrite length_code[255] to use the best encoding:
     */
    length_code[length-1] = (u8)code;

    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
    dist = 0;
    for (code = 0 ; code < 16; code++) {
        base_dist[code] = dist;
        for (n = 0; n < (1<<extra_dbits[code]); n++) {
            dist_code[dist++] = (u8)code;
        }
    }
    // Assert (dist == 256, "ct_init: dist != 256");
    dist >>= 7; /* from now on, all distances are divided by 128 */
    for ( ; code < D_CODES; code++) {
        base_dist[code] = dist << 7;
        for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
            dist_code[256 + dist++] = (u8)code;
        }
    }
    // Assert (dist == 256, "ct_init: 256+dist != 512");

    /* Construct the codes of the static literal tree */
    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
    n = 0;
    while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
    while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
    while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
    while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
    /* Codes 286 and 287 do not exist, but we must include them in the
     * tree construction to get a canonical Huffman tree (longest code
     * all ones)
     */
    gen_codes((ct_data *)static_ltree, L_CODES+1);

    /* The static distance tree is trivial: */
    for (n = 0; n < D_CODES; n++) {
        static_dtree[n].Len = 5;
        static_dtree[n].Code = bi_reverse(n, 5);
    }

    /* Initialize the first block of the first file: */
    init_block();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movzwl 0x6c53(%rip), %eax      # 0x11ac2
cmpl $0x0, %eax
je 0xae79
jmp 0xb18d
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x1c, -0x10(%rbp)
jge 0xaef8
movl -0xc(%rbp), %edx
movslq -0x10(%rbp), %rcx
leaq 0x7ba5(%rip), %rax      # 0x12a40
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x55ed(%rip), %rcx      # 0x104a0
movl (%rcx,%rdx,4), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0xaeeb
movl -0x10(%rbp), %eax
movb %al, %dl
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0x7863(%rip), %rax      # 0x12740
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xaea5
jmp 0xaeed
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xae87
movl -0x10(%rbp), %eax
movb %al, %dl
movl -0xc(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x7833(%rip), %rax      # 0x12740
movb %dl, (%rax,%rcx)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x10, -0x10(%rbp)
jge 0xaf8f
movl -0x14(%rbp), %edx
movslq -0x10(%rbp), %rcx
leaq 0x7b8e(%rip), %rax      # 0x12ac0
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x55d6(%rip), %rcx      # 0x10520
movl (%rcx,%rdx,4), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0xaf82
movl -0x10(%rbp), %eax
movb %al, %dl
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %eax, %rcx
leaq 0x78cc(%rip), %rax      # 0x12840
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xaf3c
jmp 0xaf84
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xaf1e
movl -0x14(%rbp), %eax
sarl $0x7, %eax
movl %eax, -0x14(%rbp)
cmpl $0x1e, -0x10(%rbp)
jge 0xb014
movl -0x14(%rbp), %edx
shll $0x7, %edx
movslq -0x10(%rbp), %rcx
leaq 0x7b11(%rip), %rax      # 0x12ac0
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movslq -0x10(%rbp), %rdx
leaq 0x5559(%rip), %rcx      # 0x10520
movl (%rcx,%rdx,4), %ecx
subl $0x7, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0xb007
movl -0x10(%rbp), %eax
movb %al, %dl
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
addl $0x100, %eax            # imm = 0x100
movslq %eax, %rcx
leaq 0x7847(%rip), %rax      # 0x12840
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xafb9
jmp 0xb009
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xaf98
movl $0x0, -0x8(%rbp)
cmpl $0xf, -0x8(%rbp)
jg 0xb03d
movslq -0x8(%rbp), %rcx
leaq 0x6bb4(%rip), %rax      # 0x11be0
movw $0x0, (%rax,%rcx,2)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xb01b
movl $0x0, -0x4(%rbp)
cmpl $0x8f, -0x4(%rbp)
jg 0xb07d
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x4(%rbp)
movslq %eax, %rcx
leaq 0x65de(%rip), %rax      # 0x11640
movw $0x8, 0x2(%rax,%rcx,4)
movw 0x6b80(%rip), %ax       # 0x11bf0
addw $0x1, %ax
movw %ax, 0x6b75(%rip)       # 0x11bf0
jmp 0xb044
jmp 0xb07f
cmpl $0xff, -0x4(%rbp)
jg 0xb0b8
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x4(%rbp)
movslq %eax, %rcx
leaq 0x65a3(%rip), %rax      # 0x11640
movw $0x9, 0x2(%rax,%rcx,4)
movw 0x6b47(%rip), %ax       # 0x11bf2
addw $0x1, %ax
movw %ax, 0x6b3c(%rip)       # 0x11bf2
jmp 0xb07f
jmp 0xb0ba
cmpl $0x117, -0x4(%rbp)      # imm = 0x117
jg 0xb0f3
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x4(%rbp)
movslq %eax, %rcx
leaq 0x6568(%rip), %rax      # 0x11640
movw $0x7, 0x2(%rax,%rcx,4)
movw 0x6b08(%rip), %ax       # 0x11bee
addw $0x1, %ax
movw %ax, 0x6afd(%rip)       # 0x11bee
jmp 0xb0ba
jmp 0xb0f5
cmpl $0x11f, -0x4(%rbp)      # imm = 0x11F
jg 0xb12e
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x4(%rbp)
movslq %eax, %rcx
leaq 0x652d(%rip), %rax      # 0x11640
movw $0x8, 0x2(%rax,%rcx,4)
movw 0x6acf(%rip), %ax       # 0x11bf0
addw $0x1, %ax
movw %ax, 0x6ac4(%rip)       # 0x11bf0
jmp 0xb0f5
leaq 0x650b(%rip), %rdi      # 0x11640
movl $0x11f, %esi            # imm = 0x11F
callq 0x8fe0
movl $0x0, -0x4(%rbp)
cmpl $0x1e, -0x4(%rbp)
jge 0xb188
movslq -0x4(%rbp), %rcx
leaq 0x6969(%rip), %rax      # 0x11ac0
movw $0x5, 0x2(%rax,%rcx,4)
movl -0x4(%rbp), %edi
movl $0x5, %esi
callq 0x8f90
movw %ax, %dx
movslq -0x4(%rbp), %rcx
leaq 0x6947(%rip), %rax      # 0x11ac0
movw %dx, (%rax,%rcx,4)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xb146
callq 0x90a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)