// File: /workspace/github_c_makefile_star2_O3/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
movl $0xe, %ebx
callq 0x1030
decl %ebx
jne 0x116f
movq 0x2e61(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x2f27(%rip), %rdi      # 0x40b0
movl $0x1, %esi
movl $0x1200, %edx           # imm = 0x1200
callq 0x1050
leaq 0x2f16(%rip), %rcx      # 0x40b5
movl $0x4, %r13d
xorl %eax, %eax
movl $0x2, %ebp
movl $0x3, %r14d
movq %rax, (%rsp)
movq $-0x2, %rax
movq %rcx, 0x8(%rsp)
leaq 0x10(%rsp), %rdx
movb -0x5(%rcx), %dil
movb -0x4(%rcx), %r8b
movb -0x3(%rcx), %sil
movzbl %r12b, %r9d
testb %sil, %sil
movl %r9d, %r10d
movl $0x0, %r15d
cmovel %r15d, %r10d
movl %edi, %r11d
orb %r8b, %r11b
cmovnel %r9d, %r10d
testb %sil, %sil
movl %r10d, %r9d
movl $0x1, %r11d
cmovnel %r11d, %r9d
movl %edi, %r11d
orb %r8b, %r11b
cmovnel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
cmovel %ebp, %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
cmovnel %r14d, %r9d
testb %r12b, %dil
cmovel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
cmovel %r13d, %r10d
testb %r8b, %r11b
cmovel %r9d, %r10d
testb %sil, %sil
movl %r10d, %r9d
movl $0x5, %ebx
cmovnel %ebx, %r9d
testb %r8b, %r11b
cmovel %r10d, %r9d
testb %sil, %sil
movl %r9d, %r10d
movl $0x6, %r11d
cmovel %r11d, %r10d
testb %r8b, %dil
cmovel %r9d, %r10d
testb %sil, %sil
movl %r10d, %esi
movl $0x7, %r9d
cmovnel %r9d, %esi
testb %r8b, %dil
cmovel %r10d, %esi
movb -0x2(%rcx), %r8b
movb -0x1(%rcx), %r9b
movb (%rcx), %dil
testb %dil, %dil
movl %esi, %r10d
cmovel %r15d, %r10d
movl %r8d, %r11d
orb %r9b, %r11b
cmovnel %esi, %r10d
testb %dil, %dil
movl %r10d, %r11d
movl $0x1, %r15d
cmovnel %r15d, %r11d
movl %r8d, %r12d
orb %r9b, %r12b
cmovnel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
cmovel %ebp, %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
cmovnel %r14d, %r11d
testb %r13b, %r8b
movl $0x4, %r13d
cmovel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
cmovel %r13d, %r10d
testb %r9b, %r12b
cmovel %r11d, %r10d
testb %dil, %dil
movl %r10d, %r11d
cmovnel %ebx, %r11d
testb %r9b, %r12b
cmovel %r10d, %r11d
testb %dil, %dil
movl %r11d, %r10d
movl $0x6, %ebx
cmovel %ebx, %r10d
testb %r9b, %r8b
cmovel %r11d, %r10d
testb %dil, %dil
movl %r10d, %r12d
movl $0x7, %edi
cmovnel %edi, %r12d
testb %r9b, %r8b
cmovel %r10d, %r12d
shlb $0x3, %sil
addb %r12b, %sil
movb %sil, (%rdx)
addq $0x2, %rax
incq %rdx
addq $0x6, %rcx
cmpq $0x3e, %rax
jb 0x11c7
movq $-0x4, %r13
movzbl 0x14(%rsp,%r13), %eax
shll $0x2, %eax
movzbl 0x15(%rsp,%r13), %r15d
movl %r15d, %edi
shrl $0x4, %edi
orl %eax, %edi
callq 0x1040
shll $0x4, %r15d
movzbl 0x16(%rsp,%r13), %ebx
movl %ebx, %edi
shrl $0x2, %edi
orl %r15d, %edi
callq 0x1040
shll $0x2, %ebx
movzbl 0x17(%rsp,%r13), %edi
orl %ebx, %edi
callq 0x1040
addq $0x4, %r13
cmpq $0x1c, %r13
jb 0x1383
movq (%rsp), %rax
incq %rax
movq 0x8(%rsp), %rcx
addq $0xc0, %rcx
cmpq $0x18, %rax
movl $0x4, %r13d
jne 0x11b2
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq