// File: /workspace/github_cpp_makefile_star2_O2/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, -0x34(%rbp)
movl %edx, -0x30(%rbp)
movq %rdi, -0x48(%rbp)
movq %rsi, -0x40(%rbp)
movl 0x24(%rsi), %r13d
xorl %edi, %edi
cmpl $0x1001, %r13d          # imm = 0x1001
jne 0xedf44
xorl %edi, %edi
movl -0x30(%rbp), %esi
callq 0xebd0
movzbl %al, %r13d
pushq $0x1
popq %rax
movl %eax, %edi
movq -0x48(%rbp), %r14
cmpl -0x34(%rbp), %edi
jge 0xee052
leal 0x1(%rdi), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %esi
callq 0xebd0
movslq %r13d, %r12
movq %r12, %rcx
shlq $0x8, %rcx
movzbl %al, %r15d
leaq (%r15,%rcx), %rbx
shrq $0x4, %r12
xorl %ebx, %r12d
leaq 0x117399(%rip), %rax    # 0x205318
movq (%rax), %rax
movl %r12d, %ecx
andl $0x1fff, %ecx           # imm = 0x1FFF
movq (%rax,%rcx,8), %rdx
movq %rdx, %rsi
shrq $0xc, %rsi
cmpq $0xfffff, %rsi          # imm = 0xFFFFF
je 0xedfb4
incl %ecx
cmpq %rbx, %rsi
jne 0xedf85
andl $0xfff, %edx            # imm = 0xFFF
movl %edx, %r13d
jmp 0xee048
movq %r14, %rdi
movq -0x40(%rbp), %rsi
movl %r13d, %edx
movq %rsi, %r13
callq 0xedcf8
movl 0x14(%r13), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jl 0xee004
movl 0xc(%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0xedcf8
movl 0x8(%r13), %ecx
movl 0x10(%r13), %eax
incl %eax
movl %eax, 0x14(%r13)
incl %ecx
movl %ecx, 0x18(%r13)
pushq $0x1
popq %rax
shll %cl, %eax
movl %eax, 0x1c(%r13)
callq 0xedccf
jmp 0xee045
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%r13)
leaq 0x117306(%rip), %rcx    # 0x205318
movq (%rcx), %rcx
movl %r12d, %edx
andl $0x1fff, %edx           # imm = 0x1FFF
movq (%rcx,%rdx,8), %rsi
shrq $0xc, %rsi
movl %edx, %r12d
incl %r12d
cmpq $0xfffff, %rsi          # imm = 0xFFFFF
jne 0xee015
shlq $0xc, %rbx
andl $0xfff, %eax            # imm = 0xFFF
orq %rbx, %rax
movq %rax, (%rcx,%rdx,8)
movl %r15d, %r13d
movl -0x2c(%rbp), %eax
movl %eax, %edi
jmp 0xedf48
movq -0x40(%rbp), %rax
movl %r13d, 0x24(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq