// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_wasm_parser.c
// Function: wasm_cmp
static void
wasm_cmp(ir_unit_t *iu, ir_bb_t *ib, int code)
{
  int cmpop = -1;
  ir_instr_binary_t *i = instr_add(ib, sizeof(ir_instr_binary_t), IR_IC_CMP2);

  switch(code) {
  case 0x45:
    i->lhs_value = value_create_const32(iu, 0, IR_TYPE_INT32);
    i->rhs_value = vstack_pop(iu);
    i->op = ICMP_EQ;
    value_alloc_instr_ret(iu, WASM_TYPE_I32, &i->super);
    vstack_push(iu, i->super.ii_ret);
    return;

  case 0x50:
    i->lhs_value = value_create_const32(iu, 0, IR_TYPE_INT64);
    i->rhs_value = vstack_pop(iu);
    i->op = ICMP_EQ;
    value_alloc_instr_ret(iu, WASM_TYPE_I32, &i->super);
    vstack_push(iu, i->super.ii_ret);
    return;

  case 0x51:
  case 0x46:  cmpop = ICMP_EQ;   break;
  case 0x52:
  case 0x47:  cmpop = ICMP_NE;   break;
  case 0x53:
  case 0x48:  cmpop = ICMP_SLT;  break;
  case 0x54:
  case 0x49:  cmpop = ICMP_ULT;  break;
  case 0x55:
  case 0x4a:  cmpop = ICMP_SGT;  break;
  case 0x56:
  case 0x4b:  cmpop = ICMP_UGT;  break;
  case 0x57:
  case 0x4c:  cmpop = ICMP_SLE;  break;
  case 0x58:
  case 0x4d:  cmpop = ICMP_ULE;  break;
  case 0x59:
  case 0x4e:  cmpop = ICMP_SGE;  break;
  case 0x5a:
  case 0x4f:  cmpop = ICMP_UGE;  break;

  case 0x61:
  case 0x5b:  cmpop = FCMP_OEQ;   break;
  case 0x62:
  case 0x5c:  cmpop = FCMP_UNE;   break;
  case 0x63:
  case 0x5d:  cmpop = FCMP_OLT;   break;
  case 0x64:
  case 0x5e:  cmpop = FCMP_OGT;   break;
  case 0x65:
  case 0x5f:  cmpop = FCMP_OLE;   break;
  case 0x66:
  case 0x60:  cmpop = FCMP_OGE;   break;
  default:
    parser_error(iu, "Can't handle cmp 0x%x", code);
  }

  i->rhs_value = vstack_pop(iu);
  i->lhs_value = vstack_pop(iu);
  i->op = cmpop;
  value_alloc_instr_ret(iu, WASM_TYPE_I32, &i->super);
  vstack_push(iu, i->super.ii_ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x70, %esi
movl $0x7, %edx
callq 0x20c10
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $-0x45, %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x21, %eax
ja 0x21b50
movq -0x58(%rbp), %rax
leaq 0x1b8c4(%rip), %rcx     # 0x3d268
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x1f0f0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, 0x5c(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1ea10
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq %rcx, 0x64(%rax)
movq -0x20(%rbp), %rax
movl $0x20, 0x58(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
callq 0x22410
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x2c(%rax), %rsi
callq 0x1f360
jmp 0x21bed
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x1f0f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq %rcx, 0x5c(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1ea10
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, 0x64(%rax)
movq -0x20(%rbp), %rax
movl $0x20, 0x58(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
callq 0x22410
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x2c(%rax), %rsi
callq 0x1f360
jmp 0x21bed
movl $0x20, -0x18(%rbp)
jmp 0x21b72
movl $0x21, -0x18(%rbp)
jmp 0x21b72
movl $0x28, -0x18(%rbp)
jmp 0x21b72
movl $0x24, -0x18(%rbp)
jmp 0x21b72
movl $0x26, -0x18(%rbp)
jmp 0x21b72
movl $0x22, -0x18(%rbp)
jmp 0x21b72
movl $0x29, -0x18(%rbp)
jmp 0x21b72
movl $0x25, -0x18(%rbp)
jmp 0x21b72
movl $0x27, -0x18(%rbp)
jmp 0x21b72
movl $0x23, -0x18(%rbp)
jmp 0x21b72
movl $0x1, -0x18(%rbp)
jmp 0x21b72
movl $0xe, -0x18(%rbp)
jmp 0x21b72
movl $0x4, -0x18(%rbp)
jmp 0x21b72
movl $0x2, -0x18(%rbp)
jmp 0x21b72
movl $0x5, -0x18(%rbp)
jmp 0x21b72
movl $0x3, -0x18(%rbp)
jmp 0x21b72
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %r8d
leaq 0x1cc7d(%rip), %rsi     # 0x3e7dc
movl $0x2ea, %edx            # imm = 0x2EA
leaq 0x1d483(%rip), %rcx     # 0x3efee
movb $0x0, %al
callq 0x18220
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1ea10
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x48(%rbp)
movq -0x48(%rbp), %rcx
movq %rcx, 0x64(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1ea10
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq %rcx, 0x5c(%rax)
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
callq 0x22410
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x2c(%rax), %rsi
callq 0x1f360
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)