// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/t_elf32arm.c
// Function: armle_reloc_vlink2elf
static uint8_t armle_reloc_vlink2elf(struct Reloc *r)
/* Try to map vlink-internal representation to a valid ELF reloc type */
{
  struct RelocInsert *ri;

  if (ri = r->insert) {
    int pos = (int)ri->bpos;
    int size = (int)ri->bsiz;
    lword mask = ri->mask;
    struct RelocInsert *ri2 = ri->next;

    switch (r->rtype) {
      case R_ABS:
        if (!(pos&7) && mask==-1 && !ri2) {
          switch (size) {
            case 32: return R_ARM_ABS32;
            case 16: return R_ARM_ABS16;
            case 8: return R_ARM_ABS8;
          }
        }
        else if (size==24 && (pos&31)==8 && mask==0xffffff && !ri2)
          return R_ARM_SWI24; /* @@@ obsolete */
        else if (size==12 && (pos&31)==20 && mask==0xfff && !ri2)
          return R_ARM_ABS12;
        else if (size==8 && (pos&15)==8 && mask==0xff && !ri2)
          return R_ARM_THM_SWI8; /* @@@ obsolete */
        else if (size==5 && (pos&15)==5 && mask==0x1f && !ri2)
          return R_ARM_THM_ABS5;
        break;

      case R_PC:
        if (size==32 && !(pos&7) && mask==-1 && !ri2)
          return R_ARM_REL32;
        else if (size==24 && (pos&31)==8 && mask==0x3fffffc && !ri2)
          return R_ARM_PC24;  /* @@@ deprecated: use R_ARM_CALL/JUMP24!!! */
        else if (size==12 && (pos&31)==20 && mask==0x1fff && !ri2)
          return R_ARM_LDR_PC_G0;
        else if (size==8 && (pos&31)==24 && mask==0xff && !ri2)
          return R_ARM_ALU_PCREL_7_0;  /* @@@ obsolete */
        else if (size==8 && (pos&31)==24 && mask==0xff00 && !ri2)
          return R_ARM_ALU_PCREL_15_8;  /* @@@ obsolete */
        else if (size==8 && (pos&31)==24 && mask==0xff0000 && !ri2)
          return R_ARM_ALU_PCREL_23_15;  /* @@@ obsolete */
        else if (size==8 && (pos&15)==8 && mask==0x3fc && !ri2)
          return R_ARM_THM_PC8;
        else if (size==11 && (pos&15)==5 && ri2) {
          if (ri2->bsiz==11 && (ri2->bpos&15)==5) {
            if ((mask==0x7ff000 && ri2->mask==0xffe) ||
                (mask==0xffe && ri2->mask==0x7ff000))
              return R_ARM_THM_CALL;
          }
        }
        break;
    }
  }

  return R_NONE;
}

// Assembly:
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x1b023
movzwl 0x8(%rax), %esi
movzwl 0xa(%rax), %r8d
movq (%rax), %rdx
movq 0x10(%rax), %rcx
movzbl 0x38(%rdi), %eax
cmpl $0x2, %eax
je 0x1adc0
cmpl $0x1, %eax
jne 0x1b023
testb $0x7, %sil
setne %al
cmpq $-0x1, %rcx
setne %dil
orb %al, %dil
testq %rdx, %rdx
setne %al
orb %dil, %al
je 0x1ae04
xorl %eax, %eax
cmpl $0xb, %r8d
jg 0x1ae9a
cmpl $0x5, %r8d
je 0x1afdb
cmpl $0x8, %r8d
jne 0x1ae24
testq %rdx, %rdx
setne %al
andl $0xf, %esi
cmpl $0x8, %esi
setne %dl
cmpq $0xff, %rcx
setne %cl
orb %al, %cl
orb %dl, %cl
movb $0xe, %al
jne 0x1b023
jmp 0x1ae24
xorl %eax, %eax
cmpl $0xb, %r8d
jle 0x1ae25
cmpl $0xc, %r8d
je 0x1aed8
cmpl $0x18, %r8d
je 0x1af02
cmpl $0x20, %r8d
jne 0x1ae24
testb $0x7, %sil
setne %al
cmpq $-0x1, %rcx
setne %cl
orb %al, %cl
testq %rdx, %rdx
setne %al
orb %cl, %al
movb $0x3, %al
jne 0x1b023
jmp 0x1ae24
cmpl $0x8, %r8d
je 0x1afd8
cmpl $0x20, %r8d
je 0x1afd5
cmpl $0x10, %r8d
jne 0x1b023
movb $0x5, %al
retq
cmpl $0x8, %r8d
je 0x1af2c
cmpl $0xb, %r8d
jne 0x1ae24
andl $0xf, %esi
cmpl $0x5, %esi
sete %al
testq %rdx, %rdx
setne %sil
andb %al, %sil
cmpb $0x1, %sil
jne 0x1b023
cmpw $0xb, 0xa(%rdx)
jne 0x1b023
movzwl 0x8(%rdx), %eax
andl $0xf, %eax
cmpw $0x5, %ax
jne 0x1b023
cmpq $0xffe, %rcx            # imm = 0xFFE
je 0x1b026
cmpq $0x7ff000, %rcx         # imm = 0x7FF000
jne 0x1b023
movb $0xa, %al
cmpq $0xffe, 0x10(%rdx)      # imm = 0xFFE
jne 0x1b023
jmp 0x1ae24
cmpl $0xc, %r8d
je 0x1affe
cmpl $0x18, %r8d
jne 0x1ae24
testq %rdx, %rdx
setne %al
andl $0x1f, %esi
cmpl $0x8, %esi
setne %dl
cmpq $0xffffff, %rcx         # imm = 0xFFFFFF
setne %cl
orb %al, %cl
orb %dl, %cl
movb $0xd, %al
jne 0x1b023
jmp 0x1ae24
andl $0x1f, %esi
cmpl $0x14, %esi
setne %al
cmpq $0x1fff, %rcx           # imm = 0x1FFF
setne %cl
testq %rdx, %rdx
setne %dl
orb %cl, %dl
orb %al, %dl
movb $0x4, %al
jne 0x1b023
jmp 0x1ae24
andl $0x1f, %esi
cmpl $0x8, %esi
setne %al
cmpq $0x3fffffc, %rcx        # imm = 0x3FFFFFC
setne %cl
testq %rdx, %rdx
setne %dl
orb %cl, %dl
orb %al, %dl
movb $0x1, %al
jne 0x1b023
jmp 0x1ae24
movl %esi, %edi
andl $0x1f, %edi
cmpl $0x18, %edi
setne %al
cmpq $0xff, %rcx
setne %r8b
testq %rdx, %rdx
setne %r9b
orb %r8b, %r9b
orb %al, %r9b
movb $0x20, %al
cmpb $0x1, %r9b
jne 0x1ae24
testq %rdx, %rdx
setne %al
cmpl $0x18, %edi
setne %r8b
cmpq $0xff00, %rcx           # imm = 0xFF00
setne %r9b
orb %al, %r9b
orb %r8b, %r9b
movb $0x21, %al
cmpb $0x1, %r9b
jne 0x1ae24
testq %rdx, %rdx
setne %al
cmpl $0x18, %edi
setne %dil
cmpq $0xff0000, %rcx         # imm = 0xFF0000
setne %r8b
orb %al, %r8b
orb %dil, %r8b
movb $0x22, %al
cmpb $0x1, %r8b
jne 0x1ae24
testq %rdx, %rdx
setne %al
andl $0xf, %esi
cmpl $0x8, %esi
setne %dl
cmpq $0x3fc, %rcx            # imm = 0x3FC
setne %cl
orb %al, %cl
orb %dl, %cl
movb $0xb, %al
jne 0x1b023
jmp 0x1ae24
movb $0x2, %al
retq
movb $0x8, %al
retq
testq %rdx, %rdx
setne %al
andl $0xf, %esi
cmpl $0x5, %esi
setne %dl
cmpq $0x1f, %rcx
setne %cl
orb %al, %cl
orb %dl, %cl
movb $0x7, %al
jne 0x1b023
jmp 0x1ae24
testq %rdx, %rdx
setne %al
andl $0x1f, %esi
cmpl $0x14, %esi
setne %dl
cmpq $0xfff, %rcx            # imm = 0xFFF
setne %cl
orb %al, %cl
orb %dl, %cl
movb $0x6, %al
je 0x1ae24
xorl %eax, %eax
retq
movb $0xa, %al
cmpq $0x7ff000, 0x10(%rdx)   # imm = 0x7FF000
jne 0x1b023
jmp 0x1ae24
nop