// File: /workspace/github_c_makefile_star2_O0/0xADE1A1DE[P]MeasureSuite/lib/src/loader.c
// Function: load_data
int load_data(measuresuite_t ms, enum load_type type, const uint8_t *data,
              size_t data_len, const char *symbol, int *id) {
  if (type == SHARED_OBJECT) {
    ms->errorno = E_INVALID_INPUT__SO_FROM_MEMORY;
    return 1;
  }

  if (*id == -1) {
    if (create_new_function(ms, type, data_len)) {
      return 1;
    }
    *id = (int)ms->num_functions - 1;
  }

  struct function_tuple *fct = &ms->functions[*id];
  /** make sure we got enough space in case we are re-using */
  if (fct->code_size_bytes < data_len) {
    if (realloc_rwx_or_fail(ms, fct->code, fct->code_size_bytes, data_len)) {
      return 1;
    }
    fct->code_size_bytes = data_len;
  }

  switch (type) {
  case ASM: {
#ifdef USE_ASSEMBLYLINE
    if (asm_assemble_string_counting_chunks(
            fct->al, (char *)data, (int)ms->chunk_size, &fct->chunks)) {
      ms->errorno = E_LOAD__ASM_DATA;
      return 1;
    }
    return 0;
#else
    ms->errorno = E_NO_ASSEMBLYLINE;
    return 1;
#endif
  }

  case BIN: {
    memcpy(fct->code, data, data_len);
    return 0;
  }

  case ELF:
    return elf_load_symbol_mem(ms, fct->code, fct->code_size_bytes, data,
                               symbol);

  default:
    return 1;
  }

  ms->errorno = E_SUCCESS;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpl $0x3, -0x14(%rbp)
jne 0x4bcf
movq -0x10(%rbp), %rax
movl $0xa, 0x88(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x4cf3
movq -0x38(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x4c0f
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x4a40
cmpl $0x0, %eax
je 0x4bf9
movl $0x1, -0x4(%rbp)
jmp 0x4cf3
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movl %eax, %ecx
subl $0x1, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x38(%rbp), %rcx
movslq (%rcx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x28(%rbp), %rax
jae 0x4c71
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x28(%rbp), %rcx
callq 0x3990
cmpl $0x0, %eax
je 0x4c65
movl $0x1, -0x4(%rbp)
jmp 0x4cf3
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x44(%rbp)
testl %eax, %eax
je 0x4c91
jmp 0x4c7d
movl -0x44(%rbp), %eax
subl $0x1, %eax
je 0x4ca8
jmp 0x4c87
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0x4cc6
jmp 0x4cec
movq -0x10(%rbp), %rax
movl $0x21, 0x88(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x4cf3
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x21a0
movl $0x0, -0x4(%rbp)
jmp 0x4cf3
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x5020
movl %eax, -0x4(%rbp)
jmp 0x4cf3
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)