// File: buildsi[P]ldaudit-yaml/auditlib.cpp
// Function: la_symbind32
uintptr_t la_symbind32(Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
               uintptr_t *defcook, unsigned int *flags, const char *symname) {

  std::stringstream refcookie;
  refcookie << refcook;
  std::stringstream defcookie;
  defcookie << defcook;

  std::string desc;
  switch (*flags) {
    case LA_SYMB_DLSYM:
      desc = "The binding resulted from a call to dlsym(3).";     
      break;
    case LA_SYMB_ALTVALUE:
      desc = "A previous la_symbind*() call returned an alternate value for this symbol.";
      break;
    default:
      desc = "Unknown";
  }
   
  std::string output = "  - event: symbol_bind\n    name: \"" + std::string(symname) + "\"\n    function: la_symbind32\n    where_needed: " + refcookie.str() + "\n    where_defined: " + defcookie.str() +"\n    index_symbol: " + std::to_string(ndx) + "\n    description: " + desc + "\n";
  doPrint(output);

  return sym->st_value;
}

// Assembly:
subq $0x578, %rsp            # imm = 0x578
movq %rdi, 0x570(%rsp)
movl %esi, 0x56c(%rsp)
movq %rdx, 0x560(%rsp)
movq %rcx, 0x558(%rsp)
movq %r8, 0x550(%rsp)
movq %r9, 0x548(%rsp)
leaq 0x3c0(%rsp), %rdi
callq 0x3160
leaq 0x3d0(%rsp), %rdi
movq 0x560(%rsp), %rsi
callq 0x31b0
jmp 0x4cea
leaq 0x228(%rsp), %rdi
callq 0x3160
jmp 0x4cf9
leaq 0x238(%rsp), %rdi
movq 0x558(%rsp), %rsi
callq 0x31b0
jmp 0x4d10
leaq 0x208(%rsp), %rdi
callq 0x3310
movq 0x550(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
subl $0x8, %eax
je 0x4d6f
jmp 0x4d32
movl 0x1c(%rsp), %eax
subl $0x10, %eax
je 0x4da0
jmp 0x4db8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x52f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x52e9
leaq 0x27d0(%rip), %rsi      # 0x7546
leaq 0x208(%rsp), %rdi
callq 0x3300
jmp 0x4d85
jmp 0x4dd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x52dc
leaq 0x27cd(%rip), %rsi      # 0x7574
leaq 0x208(%rsp), %rdi
callq 0x3300
jmp 0x4db6
jmp 0x4dd0
leaq 0x26ea(%rip), %rsi      # 0x74a9
leaq 0x208(%rsp), %rdi
callq 0x3300
jmp 0x4dce
jmp 0x4dd0
movq 0x548(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xa7(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x3420
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
callq 0x33f0
jmp 0x4e08
leaq 0x27b0(%rip), %rsi      # 0x75bf
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x33e0
jmp 0x4e26
leaq 0x27b5(%rip), %rdx      # 0x75e2
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x3090
jmp 0x4e44
leaq 0x80(%rsp), %rdi
leaq 0x3c0(%rsp), %rsi
callq 0x3220
jmp 0x4e5b
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x31e0
jmp 0x4e7a
leaq 0x2791(%rip), %rdx      # 0x7612
leaq 0x128(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x3090
jmp 0x4e98
leaq 0x60(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x3220
jmp 0x4eac
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x31e0
jmp 0x4ec8
leaq 0x2758(%rip), %rdx      # 0x7627
leaq 0x168(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x3090
jmp 0x4ee6
movl 0x56c(%rsp), %esi
leaq 0x40(%rsp), %rdi
callq 0x33a0
jmp 0x4ef9
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x31e0
jmp 0x4f15
leaq 0x24fb(%rip), %rdx      # 0x7417
leaq 0x1a8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x3090
jmp 0x4f33
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x208(%rsp), %rdx
callq 0x3380
jmp 0x4f52
leaq 0x2381(%rip), %rdx      # 0x72da
leaq 0x1e8(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x3090
jmp 0x4f70
leaq 0x1c8(%rsp), %rdi
callq 0x3130
leaq 0x1a8(%rsp), %rdi
callq 0x3130
leaq 0x188(%rsp), %rdi
callq 0x3130
leaq 0x40(%rsp), %rdi
callq 0x3130
leaq 0x168(%rsp), %rdi
callq 0x3130
leaq 0x148(%rsp), %rdi
callq 0x3130
leaq 0x60(%rsp), %rdi
callq 0x3130
leaq 0x128(%rsp), %rdi
callq 0x3130
leaq 0x108(%rsp), %rdi
callq 0x3130
leaq 0x80(%rsp), %rdi
callq 0x3130
leaq 0xe8(%rsp), %rdi
callq 0x3130
leaq 0xc8(%rsp), %rdi
callq 0x3130
leaq 0xa8(%rsp), %rdi
callq 0x3130
leaq 0xa7(%rsp), %rdi
callq 0x3260
leaq 0x20(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x30f0
jmp 0x5034
leaq 0x20(%rsp), %rdi
callq 0x38f0
jmp 0x5040
leaq 0x20(%rsp), %rdi
callq 0x3130
movq 0x570(%rsp), %rax
movl 0x4(%rax), %eax
movq %rax, (%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x3130
leaq 0x208(%rsp), %rdi
callq 0x3130
leaq 0x228(%rsp), %rdi
callq 0x31a0
leaq 0x3c0(%rsp), %rdi
callq 0x31a0
movq (%rsp), %rax
addq $0x578, %rsp            # imm = 0x578
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x528c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x527f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5272
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5265
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5258
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x524b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x523e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5234
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5227
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x521a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5210
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x5203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x51f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x3130
leaq 0x1a8(%rsp), %rdi
callq 0x3130
leaq 0x188(%rsp), %rdi
callq 0x3130
leaq 0x40(%rsp), %rdi
callq 0x3130
leaq 0x168(%rsp), %rdi
callq 0x3130
leaq 0x148(%rsp), %rdi
callq 0x3130
leaq 0x60(%rsp), %rdi
callq 0x3130
leaq 0x128(%rsp), %rdi
callq 0x3130
leaq 0x108(%rsp), %rdi
callq 0x3130
leaq 0x80(%rsp), %rdi
callq 0x3130
leaq 0xe8(%rsp), %rdi
callq 0x3130
leaq 0xc8(%rsp), %rdi
callq 0x3130
leaq 0xa8(%rsp), %rdi
callq 0x3130
leaq 0xa7(%rsp), %rdi
callq 0x3260
jmp 0x52dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x52cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x3130
leaq 0x1e8(%rsp), %rdi
callq 0x3130
leaq 0x208(%rsp), %rdi
callq 0x3130
leaq 0x228(%rsp), %rdi
callq 0x31a0
leaq 0x3c0(%rsp), %rdi
callq 0x31a0
movq 0x3b8(%rsp), %rdi
callq 0x3410