// File: /workspace/github_cpp_makefile_star2_O1/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, -0x38(%rbp)
movl 0x24(%rsi), %r12d
xorl %r13d, %r13d
cmpl $0x1001, %r12d          # imm = 0x1001
jne 0x103fde
xorl %edi, %edi
movl -0x2c(%rbp), %esi
callq 0xf193
movzbl %al, %r12d
movl $0x1, %r13d
cmpl -0x30(%rbp), %r13d
jge 0x10414d
movq %rbx, -0x40(%rbp)
movl $0xfffff000, %eax       # imm = 0xFFFFF000
leaq 0xfff(%rax), %r14
movl %r13d, %edi
movl -0x2c(%rbp), %esi
callq 0xf193
movslq %r12d, %rbx
shlq $0x8, %rbx
movzbl %al, %r8d
leaq (%r8,%rbx), %r15
shrq $0xc, %rbx
xorq %r15, %rbx
leaq 0x1172f8(%rip), %rax    # 0x21b318
movq (%rax), %rcx
movl %ebx, %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movq (%rcx,%rax,8), %rdx
movq %rdx, %rsi
shrq $0xc, %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq $0xfffff, %rsi          # imm = 0xFFFFF
je 0x104073
cmpq %r15, %rsi
je 0x10406b
movl %ebx, %esi
incl %esi
andl $0x1fff, %esi           # imm = 0x1FFF
movq (%rcx,%rsi,8), %rdx
movq %rdx, %rdi
shrq $0xc, %rdi
cmpq $0xfffff, %rdi          # imm = 0xFFFFF
je 0x104073
cmpq %r15, %rdi
jne 0x10404a
andl $0xfff, %edx            # imm = 0xFFF
movl %edx, %eax
testl %eax, %eax
jns 0x10413b
movq %r8, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl %r12d, %edx
movq %rsi, %r12
callq 0x103d7a
movl 0x14(%r12), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jl 0x1040f1
movl 0xc(%r12), %edx
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x103d7a
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 0x11723e(%rip), %rax    # 0x21b318
movq (%rax), %rax
xorl %ecx, %ecx
movq %r14, (%rax,%rcx,8)
incq %rcx
cmpq $0x2000, %rcx           # imm = 0x2000
jne 0x1040df
jmp 0x104137
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%r12)
leaq 0x117218(%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 0x10410f
shlq $0xc, %r15
andl $0xfff, %eax            # imm = 0xFFF
orq %r15, %rax
movq %rax, (%rcx,%rdx,8)
movq -0x48(%rbp), %rax
incl %r13d
movl %eax, %r12d
cmpl -0x30(%rbp), %r13d
jne 0x103ff8
jmp 0x104150
movl %r12d, %eax
movq -0x38(%rbp), %rcx
movl %eax, 0x24(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq