// File: /workspace/github_c_makefile_star2_O1/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 0x1b1bd
movzwl 0x8(%rax), %edx
movzwl 0xa(%rax), %esi
movq (%rax), %rcx
movq 0x10(%rax), %rax
movzbl 0x38(%rdi), %edi
cmpl $0x2, %edi
je 0x1ae96
cmpl $0x1, %edi
jne 0x1b1a1
testb $0x7, %dl
setne %dil
cmpq $-0x1, %rax
setne %r8b
orb %dil, %r8b
testq %rcx, %rcx
setne %dil
orb %r8b, %dil
je 0x1af6f
cmpl $0xb, %esi
jg 0x1af91
cmpl $0x5, %esi
je 0x1b01d
cmpl $0x8, %esi
jne 0x1b1a1
testq %rcx, %rcx
setne %dil
movl %edx, %r8d
andl $0xf, %r8d
cmpl $0x8, %r8d
setne %r8b
cmpq $0xff, %rax
setne %r9b
orb %dil, %r9b
orb %r8b, %r9b
cmpb $0x1, %r9b
jne 0x1b059
cmpl $0x5, %esi
jne 0x1b1a1
jmp 0x1b01d
cmpl $0xb, %esi
jle 0x1aee5
cmpl $0xc, %esi
je 0x1b0b9
cmpl $0x18, %esi
je 0x1b075
cmpl $0x20, %esi
jne 0x1b1a1
testb $0x7, %dl
setne %dil
cmpq $-0x1, %rax
setne %r8b
orb %dil, %r8b
testq %rcx, %rcx
setne %dil
orb %r8b, %dil
cmpb $0x1, %dil
jne 0x1b052
cmpl $0xb, %esi
jg 0x1b067
cmpl $0x8, %esi
je 0x1b0f8
cmpl $0xb, %esi
jne 0x1b1a1
andl $0xf, %edx
cmpl $0x5, %edx
sete %dl
testq %rcx, %rcx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1b1a1
cmpw $0xb, 0xa(%rcx)
jne 0x1b1a1
movzwl 0x8(%rcx), %edx
andl $0xf, %edx
cmpw $0x5, %dx
jne 0x1b1a1
cmpq $0xffe, %rax            # imm = 0xFFE
je 0x1af5a
cmpq $0x7ff000, %rax         # imm = 0x7FF000
jne 0x1b1a1
cmpq $0xffe, 0x10(%rcx)      # imm = 0xFFE
je 0x1af68
cmpq $0xffe, %rax            # imm = 0xFFE
jne 0x1b1a1
cmpq $0x7ff000, 0x10(%rcx)   # imm = 0x7FF000
jne 0x1b1a1
movb $0xa, %al
jmp 0x1b1b7
cmpl $0x8, %esi
je 0x1b04b
cmpl $0x20, %esi
je 0x1b044
cmpl $0x10, %esi
jne 0x1b1a1
movb $0x5, %al
jmp 0x1b1b7
cmpl $0xc, %esi
je 0x1afe6
cmpl $0x18, %esi
jne 0x1b1a1
testq %rcx, %rcx
setne %dil
movl %edx, %r8d
andl $0x1f, %r8d
cmpl $0x8, %r8d
setne %r8b
cmpq $0xffffff, %rax         # imm = 0xFFFFFF
setne %r9b
orb %dil, %r9b
orb %r8b, %r9b
cmpb $0x1, %r9b
jne 0x1b060
cmpl $0x5, %esi
je 0x1b01d
cmpl $0x8, %esi
je 0x1ae58
cmpl $0xc, %esi
jne 0x1b1a1
testq %rcx, %rcx
setne %dil
movl %edx, %r8d
andl $0x1f, %r8d
cmpl $0x14, %r8d
setne %r8b
cmpq $0xfff, %rax            # imm = 0xFFF
setne %r9b
orb %dil, %r9b
orb %r8b, %r9b
cmpb $0x1, %r9b
je 0x1ae46
movb $0x6, %al
jmp 0x1b1b7
testq %rcx, %rcx
setne %cl
andl $0xf, %edx
cmpl $0x5, %edx
setne %dl
cmpq $0x1f, %rax
setne %al
orb %cl, %al
orb %dl, %al
jne 0x1b1a1
movb $0x7, %al
jmp 0x1b1b7
movb $0x2, %al
jmp 0x1b1b7
movb $0x8, %al
jmp 0x1b1b7
movb $0x3, %al
jmp 0x1b1b7
movb $0xe, %al
jmp 0x1b1b7
movb $0xd, %al
jmp 0x1b1b7
cmpl $0xc, %esi
je 0x1b0b9
cmpl $0x18, %esi
jne 0x1b1a1
movl %edx, %edi
andl $0x1f, %edi
cmpl $0x8, %edi
setne %dil
cmpq $0x3fffffc, %rax        # imm = 0x3FFFFFC
setne %r8b
testq %rcx, %rcx
setne %r9b
orb %r8b, %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x1b1ad
cmpl $0x8, %esi
je 0x1b0f8
cmpl $0xb, %esi
je 0x1aef7
cmpl $0xc, %esi
jne 0x1b1a1
movl %edx, %edi
andl $0x1f, %edi
cmpl $0x14, %edi
setne %dil
cmpq $0x1fff, %rax           # imm = 0x1FFF
setne %r8b
testq %rcx, %rcx
setne %r9b
orb %r8b, %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x1b1a9
cmpl $0xb, %esi
je 0x1aef7
cmpl $0x8, %esi
jne 0x1b1a1
movl %edx, %edi
andl $0x1f, %edi
cmpl $0x18, %edi
setne %r8b
cmpq $0xff, %rax
setne %r9b
testq %rcx, %rcx
setne %r10b
orb %r9b, %r10b
orb %r8b, %r10b
cmpb $0x1, %r10b
jne 0x1b1a5
testq %rcx, %rcx
setne %r8b
cmpl $0x18, %edi
setne %r9b
cmpq $0xff00, %rax           # imm = 0xFF00
setne %r10b
orb %r8b, %r10b
orb %r9b, %r10b
cmpb $0x1, %r10b
jne 0x1b1b1
testq %rcx, %rcx
setne %r8b
cmpl $0x18, %edi
setne %dil
cmpq $0xff0000, %rax         # imm = 0xFF0000
setne %r9b
orb %r8b, %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x1b1b5
testq %rcx, %rcx
setne %dil
movl %edx, %r8d
andl $0xf, %r8d
cmpl $0x8, %r8d
setne %r8b
cmpq $0x3fc, %rax            # imm = 0x3FC
setne %r9b
orb %dil, %r9b
orb %r8b, %r9b
cmpb $0x1, %r9b
je 0x1aeee
movb $0xb, %al
jmp 0x1b1b7
movb $0x1, %cl
jmp 0x1b1b9
movb $0x20, %al
jmp 0x1b1b7
movb $0x4, %al
jmp 0x1b1b7
movb $0x1, %al
jmp 0x1b1b7
movb $0x21, %al
jmp 0x1b1b7
movb $0x22, %al
xorl %ecx, %ecx
testb %cl, %cl
je 0x1b1bf
xorl %eax, %eax
retq