// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/unsorted0/attranim-ppm2frame.c
// Function: main
int main()
{
int a,x,y,f,r,g,b;
int col,dark,light;
unsigned char *ptr;
int i,n,v,sy;
int addr=0x5800+10;
unsigned char buf[32];

for(f=0;f<14;f++) getchar();

fread(image,1,64*24*3,stdin);

for(y=0;y<24;y++)
  {
  for(x=0;x<64;x+=2)
    {
    r=image[(y*64+x)*3  ];
    g=image[(y*64+x)*3+1];
    b=image[(y*64+x)*3+2];
    if(r==0 && g==0 && b==0) col=0;
    if(r==0 && g==0 && b!=0) col=1;
    if(r!=0 && g==0 && b==0) col=2;
    if(r!=0 && g==0 && b!=0) col=3;
    if(r==0 && g!=0 && b==0) col=4;
    if(r==0 && g!=0 && b!=0) col=5;
    if(r!=0 && g!=0 && b==0) col=6;
    if(r!=0 && g!=0 && b!=0) col=7;
    i=col;
    r=image[(y*64+x+1)*3  ];
    g=image[(y*64+x+1)*3+1];
    b=image[(y*64+x+1)*3+2];
    if(r==0 && g==0 && b==0) col=0;
    if(r==0 && g==0 && b!=0) col=1;
    if(r!=0 && g==0 && b==0) col=2;
    if(r!=0 && g==0 && b!=0) col=3;
    if(r==0 && g!=0 && b==0) col=4;
    if(r==0 && g!=0 && b!=0) col=5;
    if(r!=0 && g!=0 && b==0) col=6;
    if(r!=0 && g!=0 && b!=0) col=7;
    /* paper left, ink right */
    buf[x/2]=(i*8+col);
    }
  
  for(x=0;x<32;x+=4)
    {
    putchar((buf[x+0]<<2)|(buf[x+1]>>4));
    putchar((buf[x+1]<<4)|(buf[x+2]>>2));
    putchar((buf[x+2]<<2)|(buf[x+3]));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
pushq $0xe
popq %rbx
subl $0x1, %ebx
jb 0x1179
callq 0x1030
jmp 0x116d
movq 0x2e60(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x2f26(%rip), %rdi      # 0x40b0
pushq $0x1
popq %rsi
movl $0x1200, %edx           # imm = 0x1200
callq 0x1050
leaq 0x2f17(%rip), %rcx      # 0x40b5
xorl %eax, %eax
pushq $0x4
popq %rbp
cmpq $0x18, %rax
je 0x13e4
movq %rax, (%rsp)
leaq 0x10(%rsp), %rax
movq %rcx, 0x8(%rsp)
xorl %edx, %edx
cmpq $0x40, %rdx
jae 0x137a
movb -0x5(%rcx), %dil
movb -0x4(%rcx), %r8b
movb -0x3(%rcx), %sil
movzbl %r12b, %r9d
testb %sil, %sil
movl %r9d, %r10d
movl $0x0, %r11d
cmovel %r11d, %r10d
movl %edi, %r11d
orb %r8b, %r11b
cmovnel %r9d, %r10d
testb %sil, %sil
movl %r10d, %r9d
pushq $0x1
popq %r15
cmovnel %r15d, %r9d
movl %edi, %r11d
orb %r8b, %r11b
cmovnel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
pushq $0x2
popq %r13
cmovel %r13d, %r10d
testb %dil, %dil
sete %r11b
setne %dil
testb %r8b, %r8b
sete %r12b
setne %r8b
testb %r12b, %dil
cmovel %r9d, %r10d
testb %sil, %sil
movl %r10d, %r9d
pushq $0x3
popq %r14
cmovnel %r14d, %r9d
testb %r12b, %dil
cmovel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
cmovel %ebp, %r10d
testb %r8b, %r11b
cmovel %r9d, %r10d
testb %sil, %sil
movl %r10d, %r9d
movq %rax, %r14
pushq $0x5
popq %rax
cmovnel %eax, %r9d
testb %r8b, %r11b
cmovel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
movq %rdx, %r15
pushq $0x6
popq %rdx
cmovel %edx, %r10d
testb %r8b, %dil
cmovel %r9d, %r10d
testb %sil, %sil
movl %r10d, %esi
pushq $0x7
popq %rbx
cmovnel %ebx, %esi
testb %r8b, %dil
cmovel %r10d, %esi
movb -0x2(%rcx), %r8b
movb -0x1(%rcx), %r9b
movb (%rcx), %dil
testb %dil, %dil
movl %esi, %r10d
movl $0x0, %r11d
cmovel %r11d, %r10d
movl %r8d, %r11d
orb %r9b, %r11b
cmovnel %esi, %r10d
testb %dil, %dil
movl %r10d, %r11d
pushq $0x1
popq %r12
cmovnel %r12d, %r11d
movl %r8d, %r12d
orb %r9b, %r12b
cmovnel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
cmovel %r13d, %r10d
testb %r8b, %r8b
sete %r12b
setne %r8b
testb %r9b, %r9b
sete %r13b
setne %r9b
testb %r13b, %r8b
cmovel %r11d, %r10d
testb %dil, %dil
movl %r10d, %r11d
pushq $0x3
popq %rax
cmovnel %eax, %r11d
testb %r13b, %r8b
cmovel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
cmovel %ebp, %r10d
testb %r9b, %r12b
cmovel %r11d, %r10d
testb %dil, %dil
movl %r10d, %r11d
pushq $0x5
popq %rax
cmovnel %eax, %r11d
movq %r14, %rax
testb %r9b, %r12b
cmovel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
cmovel %edx, %r10d
movq %r15, %rdx
testb %r9b, %r8b
cmovel %r11d, %r10d
testb %dil, %dil
movl %r10d, %r12d
cmovnel %ebx, %r12d
testb %r9b, %r8b
cmovel %r10d, %r12d
shlb $0x3, %sil
addb %r12b, %sil
movb %sil, (%r14)
addq $0x2, %rdx
addq $0x6, %rcx
incq %rax
jmp 0x11bd
xorl %r13d, %r13d
cmpq $0x1f, %r13
ja 0x13cc
movzbl 0x10(%rsp,%r13), %eax
shll $0x2, %eax
movzbl 0x11(%rsp,%r13), %r15d
movl %r15d, %edi
shrl $0x4, %edi
orl %eax, %edi
callq 0x1040
shll $0x4, %r15d
movzbl 0x12(%rsp,%r13), %ebx
movl %ebx, %edi
shrl $0x2, %edi
orl %r15d, %edi
callq 0x1040
shll $0x2, %ebx
movzbl 0x13(%rsp,%r13), %edi
orl %ebx, %edi
callq 0x1040
addq $0x4, %r13
jmp 0x137d
movq (%rsp), %rax
incq %rax
movq 0x8(%rsp), %rcx
addq $0xc0, %rcx
jmp 0x11a3
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq