// File: 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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1001, 0x24(%rax)     # imm = 0x1001
jne 0x167b25
movl -0x1c(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %esi
callq 0x11e40
movzbl %al, %eax
movl %eax, -0x20(%rbp)
jmp 0x167b2f
movq -0x10(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x167b31
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x167c19
movl -0x1c(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %esi
callq 0x11e40
movb %al, -0x31(%rbp)
movslq -0x20(%rbp), %rax
shlq $0x8, %rax
movzbl -0x31(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x167c30
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jl 0x167b82
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x167c14
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x1677c0
movzbl -0x31(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0xfff, 0x14(%rax)      # imm = 0xFFF
jl 0x167bfa
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x1677c0
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
callq 0x167780
jmp 0x167c12
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %esi
movl %esi, %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
callq 0x167cc0
jmp 0x167c14
jmp 0x167b31
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)