// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/stb_image_write.c
// Function: write_pixels
static void write_pixels(FILE *f, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad)
{
   unsigned char bg[3] = { 255, 0, 255}, px[3];
   stbiw_uint32 zero = 0;
   int i,j,k, j_end;

   if (y <= 0)
      return;

   if (vdir < 0) 
      j_end = -1, j = y-1;
   else
      j_end =  y, j = 0;

   for (; j != j_end; j += vdir) {
      for (i=0; i < x; ++i) {
         unsigned char *d = (unsigned char *) data + (j*x+i)*comp;
         if (write_alpha < 0)
            fwrite(&d[comp-1], 1, 1, f);
         switch (comp) {
            case 1: 
            case 2: fwrite(d, 1, 1, f);
                    break;
            case 4:
               if (!write_alpha) {
                  // composite against pink background
                  for (k=0; k < 3; ++k)
                     px[k] = bg[k] + ((d[k] - bg[k]) * d[3])/255;
                  write3(f, px[1-rgb_dir],px[1],px[1+rgb_dir]);
                  break;
               }
               /* FALLTHROUGH */
            case 3:
               write3(f, d[1-rgb_dir],d[1],d[1+rgb_dir]);
               break;
         }
         if (write_alpha > 0)
            fwrite(&d[comp-1], 1, 1, f);
      }
      fwrite(&zero,scanline_pad,1,f);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl %r9d, -0x1c(%rbp)
movw 0xc5466(%rip), %ax      # 0x4e5d74
movw %ax, -0x1f(%rbp)
movb 0xc545e(%rip), %al      # 0x4e5d76
movb %al, -0x1d(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x0, -0x18(%rbp)
jg 0x42092d
jmp 0x420b28
cmpl $0x0, -0x10(%rbp)
jge 0x420945
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x420952
movl -0x18(%rbp), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
jmp 0x420954
movl -0x30(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x420b28
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x420b04
movq 0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x2c(%rbp), %ecx
imull -0x1c(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, 0x18(%rbp)
jge 0x4209b5
movq -0x40(%rbp), %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x43cbf0
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
decl %eax
subl $0x2, %eax
jb 0x4209df
jmp 0x4209c4
movl -0x44(%rbp), %eax
subl $0x3, %eax
je 0x420a93
jmp 0x4209d2
movl -0x44(%rbp), %eax
subl $0x4, %eax
je 0x4209f9
jmp 0x420ace
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x43cbf0
jmp 0x420ace
cmpl $0x0, 0x18(%rbp)
jne 0x420a91
movl $0x0, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jge 0x420a62
movslq -0x34(%rbp), %rax
movzbl -0x1f(%rbp,%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movslq -0x34(%rbp), %rcx
movzbl -0x1f(%rbp,%rcx), %ecx
subl %ecx, %eax
movq -0x40(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
imull %ecx, %eax
movl $0xff, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x48(%rbp), %eax
addl %ecx, %eax
movb %al, %cl
movslq -0x34(%rbp), %rax
movb %cl, -0x22(%rbp,%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x420a0a
movq -0x8(%rbp), %rdi
movl $0x1, %eax
subl -0xc(%rbp), %eax
cltq
movb -0x22(%rbp,%rax), %dl
movb -0x21(%rbp), %cl
movl -0xc(%rbp), %eax
addl $0x1, %eax
cltq
movzbl %dl, %esi
movzbl %cl, %edx
movzbl -0x22(%rbp,%rax), %ecx
callq 0x420b30
jmp 0x420ace
jmp 0x420a93
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl $0x1, %ecx
subl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %sil
movq -0x40(%rbp), %rax
movb 0x1(%rax), %dl
movq -0x40(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl %sil, %esi
movzbl %dl, %edx
movzbl (%rax,%rcx), %ecx
callq 0x420b30
cmpl $0x0, 0x18(%rbp)
jle 0x420af4
movq -0x40(%rbp), %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cltq
addq %rax, %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x43cbf0
jmp 0x420af6
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x420967
movslq 0x20(%rbp), %rsi
movq -0x8(%rbp), %rcx
leaq -0x28(%rbp), %rdi
movl $0x1, %edx
callq 0x43cbf0
movl -0x10(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x420954
addq $0x50, %rsp
popq %rbp
retq
nop