// File: /workspace/github_cpp_makefile_star2_O2/alan0201tw[P]RayTracer/include/stb_image_write.h
// Function: stbi_write_hdr_core(stbi__write_context*, int, int, int, float*)
static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)
{
   if (y <= 0 || x <= 0 || data == NULL)
      return 0;
   else {
      // Each component is stored separately. Allocate scratch space for full output scanline.
      unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);
      int i, len;
      char buffer[128];
      char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
      s->func(s->context, header, sizeof(header)-1);

#ifdef __STDC_WANT_SECURE_LIB__
      len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
#else
      len = sprintf(buffer, "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
#endif
      s->func(s->context, buffer, len);

      for(i=0; i < y; i++)
         stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));
      STBIW_FREE(scratch);
      return 1;
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %ecx, %r15d
movl %edx, %ebp
testl %edx, %edx
setle %al
testl %esi, %esi
setle %cl
orb %al, %cl
movq %r8, 0x68(%rsp)
testq %r8, %r8
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x220c2
movl %esi, %r13d
movq %rdi, %r12
leal (,%r13,4), %edi
callq 0x6510
movq %rax, %r14
leaq 0x12615(%rip), %rsi     # 0x34350
pushq $0x42
popq %rcx
leaq 0x90(%rsp), %rax
movq %rax, %rdi
rep  movsb (%rsi), %es:(%rdi)
movq 0x8(%r12), %rdi
pushq $0x41
popq %rdx
movq %rax, %rsi
callq *(%r12)
leaq 0x12528(%rip), %rsi     # 0x34289
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x6070
movq 0x8(%r12), %rdi
movq %rbx, %rsi
xorl %ebx, %ebx
movl %eax, %edx
callq *(%r12)
movl %r15d, %eax
imull %r13d, %eax
movl %eax, 0x4c(%rsp)
movl %r13d, %eax
shrl $0x8, %eax
movl %eax, 0x48(%rsp)
leal -0x8000(%r13), %eax
movl %eax, 0x44(%rsp)
leal (,%r13,2), %eax
leal (%r13,%r13,2), %ecx
movslq %r15d, %rdx
addl $-0x3, %r15d
movl %r13d, %esi
leaq (%r14,%rsi), %rdi
movq %rdi, 0x78(%rsp)
addq %r14, %rax
movq %rax, 0x60(%rsp)
movq %r14, 0x20(%rsp)
addq %r14, %rcx
movq %rcx, 0x80(%rsp)
shlq $0x2, %rdx
movq %rdx, 0x58(%rsp)
movl %ebp, 0x50(%rsp)
movq %r13, 0x28(%rsp)
movq %rsi, 0x18(%rsp)
movl %r15d, 0x54(%rsp)
cmpl %ebp, %ebx
je 0x220b5
movl %ebx, %eax
notl %eax
addl %ebp, %eax
cmpl $0x0, 0x2671b(%rip)     # 0x4852c
movq %rbx, 0x70(%rsp)
cmovel %ebx, %eax
imull 0x4c(%rsp), %eax
cltq
movq 0x68(%rsp), %rcx
leaq (%rcx,%rax,4), %r14
movl $0x202, 0x14(%rsp)      # imm = 0x202
movl 0x48(%rsp), %eax
movb %al, 0x16(%rsp)
movb %r13b, 0x17(%rsp)
cmpl $0xffff8008, 0x44(%rsp) # imm = 0xFFFF8008
jae 0x21eac
movq %rsi, %rbx
subq $0x1, %rbx
jb 0x220a0
cmpl $0x1, %r15d
ja 0x21e68
movss 0x8(%r14), %xmm0
movsd (%r14), %xmm1
jmp 0x21e74
movss (%r14), %xmm0
movaps %xmm0, %xmm1
shufps $0x0, %xmm0, %xmm1      # xmm1 = xmm1[0,0],xmm0[0,0]
movss %xmm0, 0x40(%rsp)
movlps %xmm1, 0x38(%rsp)
leaq 0x10(%rsp), %r13
movq %r13, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2d1f8
movq 0x8(%r12), %rdi
movq %r13, %rsi
pushq $0x4
popq %rdx
callq *(%r12)
addq 0x58(%rsp), %r14
movq 0x18(%rsp), %rsi
jmp 0x21e4b
xorl %ebx, %ebx
movq 0x60(%rsp), %rbp
cmpq %rbx, %rsi
je 0x21f2f
cmpl $0x1, %r15d
ja 0x21ecb
movss 0x8(%r14), %xmm0
movsd (%r14), %xmm1
jmp 0x21ed7
movss (%r14), %xmm0
movaps %xmm0, %xmm1
shufps $0x0, %xmm0, %xmm1      # xmm1 = xmm1[0,0],xmm0[0,0]
movss %xmm0, 0x40(%rsp)
movlps %xmm1, 0x38(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2d1f8
movb 0x10(%rsp), %al
movq 0x20(%rsp), %rcx
movb %al, (%rcx,%rbx)
movb 0x11(%rsp), %al
movq 0x78(%rsp), %rcx
movb %al, (%rcx,%rbx)
movb 0x12(%rsp), %al
movb %al, (%rbp,%rbx)
movb 0x13(%rsp), %al
movq 0x80(%rsp), %rcx
movb %al, (%rcx,%rbx)
incq %rbx
addq 0x58(%rsp), %r14
movq 0x18(%rsp), %rsi
jmp 0x21eb3
movq 0x8(%r12), %rdi
leaq 0x14(%rsp), %rsi
pushq $0x4
popq %rdx
callq *(%r12)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rcx
xorl %ebp, %ebp
cmpq $0x4, %rbp
je 0x220a0
movq %rcx, 0x30(%rsp)
movq %rbp, 0x88(%rsp)
imulq %rsi, %rbp
addq 0x20(%rsp), %rbp
xorl %r15d, %r15d
movq 0x28(%rsp), %rdx
cmpl %edx, %r15d
jge 0x22083
movslq %r15d, %rax
addq $0x2, %rax
movl %r15d, %ebx
movq 0x30(%rsp), %rdi
cmpq %rsi, %rax
jge 0x21fa7
movb -0x2(%rdi,%rax), %cl
cmpb -0x1(%rdi,%rax), %cl
jne 0x21fa0
cmpb (%rdi,%rax), %cl
je 0x21fe7
incl %ebx
incq %rax
jmp 0x21f8c
movl %edx, %ebx
jmp 0x21fe7
movl $0x80, %eax
cmpl %eax, %r13d
cmovgel %eax, %r13d
leaq (%rbp,%r14), %r15
movb %r13b, 0xe(%rsp)
movq 0x8(%r12), %rdi
leaq 0xe(%rsp), %rsi
pushq $0x1
popq %rdx
callq *(%r12)
movq 0x8(%r12), %rdi
movq %r15, %rsi
movl %r13d, %edx
callq *(%r12)
addl %r13d, %r14d
movl %r14d, %r15d
movl %ebx, %r13d
movslq %r15d, %r14
subl %r15d, %r13d
jg 0x21fab
leal 0x2(%rbx), %eax
cmpl 0x28(%rsp), %eax
movq 0x18(%rsp), %rsi
jge 0x21f6f
movslq %ebx, %rbx
cmpq %rsi, %rbx
jge 0x22020
movq 0x30(%rsp), %rax
movb (%rax,%rbx), %al
cmpb (%rbp,%r14), %al
jne 0x22071
incq %rbx
jmp 0x22007
movq 0x28(%rsp), %rbx
jmp 0x22071
cmpl $0x7f, %r14d
pushq $0x7f
popq %rax
cmovgel %eax, %r14d
movslq %r15d, %rax
movb (%rbp,%rax), %al
movb %al, 0xe(%rsp)
leal -0x80(%r14), %eax
movb %al, 0xf(%rsp)
movq 0x8(%r12), %rdi
leaq 0xf(%rsp), %rsi
pushq $0x1
popq %r13
movl %r13d, %edx
callq *(%r12)
movq 0x8(%r12), %rdi
leaq 0xe(%rsp), %rsi
movl %r13d, %edx
callq *(%r12)
addl %r15d, %r14d
movl %r14d, %r15d
movl %ebx, %r14d
subl %r15d, %r14d
jg 0x22027
movq 0x18(%rsp), %rsi
jmp 0x21f6f
movq 0x88(%rsp), %rbp
incq %rbp
movq 0x30(%rsp), %rcx
addq %rsi, %rcx
movl 0x54(%rsp), %r15d
jmp 0x21f4c
movq 0x70(%rsp), %rbx
incl %ebx
movl 0x50(%rsp), %ebp
movq 0x28(%rsp), %r13
jmp 0x21dfc
movq 0x20(%rsp), %rdi
callq 0x64d0
pushq $0x1
popq %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq