// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/t_rawbin.c
// Function: ihex_write
static void ihex_write(struct GlobalVars *gv,FILE *f)
{
  bool firstsec = TRUE;
  struct LinkedSection *ls;
  unsigned long len,addr;
  uint8_t *p;

  while (ls = get_next_section(gv)) {
    if (ls->size == 0 || !(ls->flags & SF_ALLOC) || (ls->ld_flags & LSF_NOLOAD))
      continue;  /* ignore empty sections */

    if (firstsec) {
      if (gv->trace_file)
        fprintf(gv->trace_file,"Base address = 0x%08lx.\n",ls->copybase);
      firstsec = FALSE;
    }

    /* resolve all relocations and write section contents */
    calc_relocs(gv,ls);

    for (p=ls->data,addr=ls->copybase,len=ls->filesize; len>0; ) {
      int nbytes = (len>MAXIREC) ? MAXIREC : len;

      if ((((unsigned long)addr)&0xffff)+nbytes > 0xffff)
        nbytes = 0x10000 - (((unsigned long)addr) & 0xffff);
      IHexOut(f,addr,p,nbytes);
      p += nbytes;
      addr += nbytes;
      len -= nbytes;
    }
  }

  fprintf(f,":00000001FF\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq 0x1c0(%rdi), %rdi
callq 0x1e849
testq %rax, %rax
je 0x1e4bd
movq %rax, %rbp
leaq 0x77cf(%rip), %r12      # 0x25ae0
leaq 0x77a4(%rip), %r13      # 0x25abc
xorl %r14d, %r14d
cmpq $0x0, 0x48(%rbp)
je 0x1e32e
testb $0x1, 0x21(%rbp)
je 0x1e32e
testb $0x1, 0x24(%rbp)
je 0x1e347
movq 0x1c0(%r15), %rdi
callq 0x1e849
movq %rax, %rbp
testq %rax, %rax
jne 0x1e31b
jmp 0x1e4bd
testb $0x1, %r14b
jne 0x1e367
movq 0xa0(%r15), %rdi
testq %rdi, %rdi
je 0x1e367
movq 0x38(%rbp), %rdx
movq %r13, %rsi
xorl %eax, %eax
callq 0x5180
movq %r15, 0x8(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xb6e6
movq 0x50(%rbp), %rcx
testq %rcx, %rcx
je 0x1e496
movq 0x38(%rbp), %r13
movq 0x78(%rbp), %rbp
cmpq $0x20, %rcx
movl $0x20, %eax
movq %rcx, 0x20(%rsp)
cmovbq %rcx, %rax
movzwl %r13w, %ecx
movl $0x10000, %r14d         # imm = 0x10000
subl %ecx, %r14d
addl %eax, %ecx
movl $0x10000, %edx          # imm = 0x10000
cmpl %edx, %ecx
cmovbl %eax, %r14d
movq %r13, %rcx
shrq $0x10, %rcx
movzwl %cx, %edx
cmpq 0x157b7(%rip), %rdx     # 0x33b80
je 0x1e3fc
movq %rdx, 0x157ae(%rip)     # 0x33b80
shrl $0x8, %edx
leal (%rdx,%rcx), %eax
movl $0xff, %esi
andl %esi, %ecx
movl $0xfa, %r8d
subl %eax, %r8d
andl %esi, %r8d
movq %rbx, %rdi
leaq 0x76fd(%rip), %rsi      # 0x25af2
xorl %eax, %eax
callq 0x5180
movl %r14d, %edx
movl $0xff, %eax
andl %eax, %edx
movq %r13, %r15
shrq $0x8, %r15
movl %r15d, %ecx
andl %eax, %ecx
movl %r13d, %r8d
andl %eax, %r8d
movq %rbx, %rdi
leaq 0x76e7(%rip), %rsi      # 0x25b09
xorl %eax, %eax
callq 0x5180
movl %r14d, %eax
movq %rax, 0x10(%rsp)
addl %r13d, %r15d
addl %r14d, %r15d
incl %r14d
movq %rbp, 0x18(%rsp)
movzbl (%rbp), %edx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x5180
addb (%rbp), %r15b
incq %rbp
decl %r14d
cmpl $0x1, %r14d
ja 0x1e43f
negb %r15b
movzbl %r15b, %edx
movq %rbx, %rdi
leaq 0x7692(%rip), %rsi      # 0x25b03
xorl %eax, %eax
callq 0x5180
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rax
addq %rax, %rbp
addq %rax, %r13
movq 0x20(%rsp), %rcx
subq %rax, %rcx
jne 0x1e38c
movq 0x8(%rsp), %r15
movq 0x1c0(%r15), %rdi
callq 0x1e849
movq %rax, %rbp
movb $0x1, %r14b
testq %rax, %rax
leaq 0x7605(%rip), %r13      # 0x25abc
jne 0x1e31b
leaq 0x7621(%rip), %rdi      # 0x25ae5
movl $0xc, %esi
movl $0x1, %edx
movq %rbx, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5270