// File: /workspace/github_c_makefile_star2_O0/pali[P]bmfdec/./bmfparse.c
// Function: parse_string
static char *parse_string(char *buf, uint32_t size) {
  uint16_t *buf2 = (uint16_t *)buf;
  if (size % 2 != 0) error("Invalid size");
  char *out = malloc(size+1);
  if (!out) error("malloc failed");
  uint32_t i, j;
  for (i=0, j=0; i<size/2; ++i) {
    if (buf2[i] == 0) {
      break;
    } else if (buf2[i] < 0x80) {
      out[j++] = buf2[i];
    } else if (buf2[i] < 0x800) {
      out[j++] = 0xC0 | (buf2[i] >> 6);
      out[j++] = 0x80 | (buf2[i] & 0x3F);
    } else if (buf2[i] >= 0xD800 && buf2[i] <= 0xDBFF && i+1 < size/2 && buf2[i+1] >= 0xDC00 && buf2[i+1] <= 0xDFFF) {
      uint32_t c = 0x10000 + ((buf2[i] - 0xD800) << 10) + (buf2[i+1] - 0xDC00);
      ++i;
      out[j++] = 0xF0 | (c >> 18);
      out[j++] = 0x80 | ((c >> 12) & 0x3F);
      out[j++] = 0x80 | ((c >> 6) & 0x3F);
      out[j++] = 0x80 | (c & 0x3F);
    } else {
      out[j++] = 0xE0 | (buf2[i] >> 12);
      out[j++] = 0x80 | ((buf2[i] >> 6) & 0x3F);
      out[j++] = 0x80 | (buf2[i] & 0x3F);
    }
  }
  out[j] = 0;
  return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x595a
jmp 0x5924
movq 0x56cd(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x2b46(%rip), %rsi      # 0x847b
leaq 0x2b83(%rip), %rdx      # 0x84bf
leaq 0x2dc2(%rip), %rcx      # 0x8705
movl $0x80, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x1140
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x59ac
jmp 0x5976
movq 0x567b(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x2af4(%rip), %rsi      # 0x847b
leaq 0x2d84(%rip), %rdx      # 0x8712
leaq 0x2d70(%rip), %rcx      # 0x8705
movl $0x82, %r8d
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1180
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl -0xc(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x5c51
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0x59df
jmp 0x5c51
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x80, %eax
jge 0x5a17
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movw (%rax,%rcx,2), %ax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x5c3f
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x800, %eax            # imm = 0x800
jge 0x5a80
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
sarl $0x6, %eax
orl $0xc0, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x5c3d
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xd800, %eax           # imm = 0xD800
jl 0x5bbd
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xdbff, %eax           # imm = 0xDBFF
jg 0x5bbd
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl -0xc(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jae 0x5bbd
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xdc00, %eax           # imm = 0xDC00
jl 0x5bbd
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xdfff, %eax           # imm = 0xDFFF
jg 0x5bbd
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
subl $0xd800, %eax           # imm = 0xD800
shll $0xa, %eax
addl $0x10000, %eax          # imm = 0x10000
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzwl (%rcx,%rdx,2), %ecx
subl $0xdc00, %ecx           # imm = 0xDC00
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x12, %eax
orl $0xf0, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
shrl $0xc, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x5c3b
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
sarl $0xc, %eax
orl $0xe0, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
sarl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x28(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x5c3d
jmp 0x5c3f
jmp 0x5c41
jmp 0x5c43
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x59ba
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)