// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: write_gif_line(_IO_FILE*, GifEncoder*, int, int)
void write_gif_line(FILE *file, GifEncoder *encoder, int line, int length)
{
int i, current_code, new_code;
unsigned long new_key;
unsigned char pixval;

    i = 0;

    if(encoder->current_code == FIRST_CODE) current_code = get_pixel(i++, line);
    else current_code = encoder->current_code;

    while(i<length) {
       pixval = get_pixel(i++, line); /* Fetch next pixel from screen */

       /* Form a new unique key to search hash table for the code
        * Combines current_code as prefix string with pixval as
        * postfix char */
       new_key = (((unsigned long) current_code) << 8) + pixval;
       if((new_code = lookup_gif_hash(new_key)) >= 0) {
           /* This key is already there, or the string is old,
            * so simply take new code as current_code */
           current_code = new_code;
       }
       else {
           /* Put it in hash table, output the prefix code,
            * and make current_code equal to pixval */
           write_gif_code(file, encoder, current_code);
           current_code = pixval;

           /* If the hash_table if full, send a clear first
            * then clear the hash table: */
           if(encoder->running_code >= LZ_MAX_CODE) {
              write_gif_code(file, encoder, encoder->clear_code);
              encoder->running_code = encoder->eof_code + 1;
              encoder->running_bits = encoder->depth + 1;
              encoder->max_code_plus_one = 1 << encoder->running_bits;
              clear_gif_hash_table();
           }
           else {
              /* Put this unique key with its relative code in hash table */
              add_gif_hash_entry(new_key, encoder->running_code++);
           }
       }
    }

    /* Preserve the current state of the compression algorithm: */
    encoder->current_code = current_code;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, -0x30(%rbp)
movl %edx, -0x2c(%rbp)
movq %rdi, %rbx
movq %rsi, -0x40(%rbp)
movl 0x24(%rsi), %r12d
xorl %r13d, %r13d
cmpl $0x1001, %r12d          # imm = 0x1001
jne 0x1046b5
xorl %edi, %edi
movl -0x2c(%rbp), %esi
callq 0xf11f
movzbl %al, %r12d
movl $0x1, %r13d
cmpl -0x30(%rbp), %r13d
jge 0x10482d
movq %rbx, -0x50(%rbp)
movl $0xfffff000, %eax       # imm = 0xFFFFF000
leaq 0xfff(%rax), %r14
movl %r13d, %edi
movl -0x2c(%rbp), %esi
callq 0xf11f
movslq %r12d, %rbx
shlq $0x8, %rbx
movzbl %al, %edi
leaq (%rdi,%rbx), %r15
shrq $0xc, %rbx
xorq %r15, %rbx
leaq 0x116c22(%rip), %rax    # 0x21b318
movq (%rax), %rax
movl %ebx, %ecx
andl $0x1fff, %ecx           # imm = 0x1FFF
movq (%rax,%rcx,8), %rcx
movq %rcx, %rdx
shrq $0xc, %rdx
cmpq $0xfffff, %rdx          # imm = 0xFFFFF
jne 0x104799
movq %rdi, -0x48(%rbp)
movl %r13d, -0x34(%rbp)
movq -0x50(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rsi
movl %r12d, %edx
movq %rsi, %r12
callq 0x104431
movl 0x14(%r12), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jl 0x1047cd
movl 0xc(%r12), %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x104431
movl 0x8(%r12), %ecx
movl 0x10(%r12), %eax
incl %eax
movl %eax, 0x14(%r12)
incl %ecx
movl $0x1, %eax
shll %cl, %eax
movl %ecx, 0x18(%r12)
movl %eax, 0x1c(%r12)
leaq 0x116b96(%rip), %rax    # 0x21b318
movq (%rax), %rax
xorl %ecx, %ecx
movq %r14, (%rax,%rcx,8)
incq %rcx
cmpq $0x2000, %rcx           # imm = 0x2000
jne 0x104787
jmp 0x104813
cmpq %r15, %rdx
je 0x1047c5
movl %ebx, %edx
incl %edx
andl $0x1fff, %edx           # imm = 0x1FFF
movq (%rax,%rdx,8), %rcx
movq %rcx, %rsi
shrq $0xc, %rsi
cmpq $0xfffff, %rsi          # imm = 0xFFFFF
je 0x104719
cmpq %r15, %rsi
jne 0x1047a0
andl $0xfff, %ecx            # imm = 0xFFF
jmp 0x10481b
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%r12)
leaq 0x116b3c(%rip), %rcx    # 0x21b318
movq (%rcx), %rcx
movl $0xfffff000, %edi       # imm = 0xFFFFF000
movq $-0x1000, %r8           # imm = 0xF000
movl %ebx, %edx
andl $0x1fff, %edx           # imm = 0x1FFF
movq (%rcx,%rdx,8), %rsi
andq %r8, %rsi
movl %edx, %ebx
incl %ebx
cmpq %rdi, %rsi
jne 0x1047eb
shlq $0xc, %r15
andl $0xfff, %eax            # imm = 0xFFF
orq %r15, %rax
movq %rax, (%rcx,%rdx,8)
movl -0x34(%rbp), %r13d
movq -0x48(%rbp), %rcx
incl %r13d
movl %ecx, %r12d
cmpl -0x30(%rbp), %r13d
jne 0x1046cf
jmp 0x104830
movl %r12d, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x24(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq