// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_aout.c
// Function: aout_getpagedsize
uint32_t aout_getpagedsize(struct GlobalVars *gv,struct LinkedSection **ls,
                         int sec)
/* return size of section aligned to page boundaries */
{
  unsigned long pagealign = shiftcnt(fff[gv->dest_format]->page_size);

  if (sec == 0) {  /* .text */
    if (ls[1]) {  /* followed by .data */
      check_overlap(gv,ls[0],ls[1]);
      return ((ls[1]->base - ls[0]->base) + sizeof(struct aout_hdr));
    }
    else { /* align section size to page boundary */
      check_overlap(gv,ls[0],ls[2]);
      return (ls[0]->size + sizeof(struct aout_hdr) +
              align(ls[0]->base+ls[0]->size,pagealign));
    }
  }
  else if (sec == 1) {  /* .data */
    if (ls[1]) {
      check_overlap(gv,ls[1],ls[2]);
      return (ls[1]->size + align(ls[1]->base+ls[1]->size,pagealign));
    }
  }
  else if (ls[2]) {  /* .bss */
    /* parts of .bss might disappear in the last .text or .data page */
    unsigned long bytes_in_last_page = align(ls[2]->base,pagealign);

    if (bytes_in_last_page < ls[2]->size)
      return (ls[2]->size - bytes_in_last_page);
  }

  return (0);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movq 0x38(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x1195c(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movl 0x98(%rax), %edi
callq 0x8860
cltq
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x2c(%rsp)
jne 0x2e1a8
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2e142
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0x2e290
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
subq 0x40(%rcx), %rax
addq $0x20, %rax
movl %eax, 0x44(%rsp)
jmp 0x2e282
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdx
callq 0x2e290
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
addq $0x20, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rax
addq 0x48(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0x87f0
movq %rax, %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x44(%rsp)
jmp 0x2e282
cmpl $0x1, 0x2c(%rsp)
jne 0x2e220
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2e21e
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdx
callq 0x2e290
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
addq 0x48(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0x87f0
movq %rax, %rcx
movq 0x8(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x44(%rsp)
jmp 0x2e282
jmp 0x2e278
movq 0x30(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2e276
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0x87f0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x48(%rcx), %rax
jae 0x2e274
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rax), %rax
subq 0x18(%rsp), %rax
movl %eax, 0x44(%rsp)
jmp 0x2e282
jmp 0x2e276
jmp 0x2e278
jmp 0x2e27a
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopl (%rax,%rax)