// File: /workspace/github_c_makefile_star2_O3/cogbee[P]vmir-latest/src/vmir_value.c
// Function: value_print
static int
value_print(char **dstp, ir_unit_t *iu, const ir_value_t *iv,
            const ir_type_t *it)
{
  int value = iv->iv_id;
  int len = 0;
  char tmpbuf[64];

  if(it == NULL) {
    if(iv->iv_type < VECTOR_LEN(&iu->iu_types))
      it = &VECTOR_ITEM(&iu->iu_types, iv->iv_type);
  }

  switch(iv->iv_class) {
  case IR_VC_UNDEF:
    len += addstr(dstp, "<undefined>");
    break;

  case IR_VC_CE:
    len += addstr(dstp, "<constexpr>");
    break;

  case IR_VC_AGGREGATE:
    len += type_print(dstp, iu, it);
    len += addstr(dstp, " = {");
    ir_valuetype_t *values = iv->iv_data;
    for(int i = 0; i < iv->iv_num_values; i++) {
      if(i != 0)
        len += addstr(dstp, ", ");
      len += value_print_vt(dstp, iu, values[i]);
    }
    len += addstr(dstp, "}");
    break;

  case IR_VC_DEAD:
    snprintf(tmpbuf, sizeof(tmpbuf), "<dead>%%%d", value);
    len += addstr(dstp, tmpbuf);
    break;

  case IR_VC_ALIAS:
    len += addstr(dstp, "alias -> ");
    len += value_print_id(dstp, iu, iv->iv_reg);
    break;

  case IR_VC_FUNCTION:
    len += addstr(dstp, "function ");
    if(iv->iv_func->if_name != NULL) {
      len += addstr(dstp, iv->iv_func->if_name);
      len += addstr(dstp, "() ");
    }
    len += type_print_id(dstp, iu, iv->iv_func->if_type);
    break;

  case IR_VC_GLOBALVAR:
    len += addstr(dstp, "global ");
    if(iv->iv_gvar->ig_name != NULL) {
      len += addstr(dstp, iv->iv_gvar->ig_name);
      len += addstr(dstp, " ");
    }
    len += type_print(dstp, iu, it);
    snprintf(tmpbuf, sizeof(tmpbuf), " @ 0x%x", iv->iv_gvar->ig_addr);
    len += addstr(dstp, tmpbuf);
    break;

  case IR_VC_TEMPORARY:
    len += addstr(dstp, "(");
    len += type_print(dstp, iu, it);
    snprintf(tmpbuf, sizeof(tmpbuf), ")%%%d", value);
    len += addstr(dstp, tmpbuf);
    break;

  case IR_VC_CONSTANT:
    len += addstr(dstp, "(");
    len += type_print(dstp, iu, it);
    snprintf(tmpbuf, sizeof(tmpbuf), ")%%%d", value);
    len += addstr(dstp, tmpbuf);
    if(it == NULL) {
      len += addstr(dstp, "badtype");
      break;
    }

    switch(it->it_code) {
    case IR_TYPE_INT1:
      snprintf(tmpbuf, sizeof(tmpbuf), "#0x%x", !!iv->iv_u32);
      break;
    case IR_TYPE_INT8:
    case IR_TYPE_INT16:
    case IR_TYPE_INT32:
    case IR_TYPE_POINTER:
      snprintf(tmpbuf, sizeof(tmpbuf), "#0x%x", iv->iv_u32);
      break;
    case IR_TYPE_INT64:
      snprintf(tmpbuf, sizeof(tmpbuf), "#0x%"PRIx64, iv->iv_u64);
      break;
    case IR_TYPE_FLOAT:
      snprintf(tmpbuf, sizeof(tmpbuf), "#%f", iv->iv_float);
      break;
    case IR_TYPE_DOUBLE:
      snprintf(tmpbuf, sizeof(tmpbuf), "#%f", iv->iv_double);
      break;
    default:
      snprintf(tmpbuf, sizeof(tmpbuf), "#?(code-%d)", it->it_code);
      break;
    }
    len += addstr(dstp, tmpbuf);
    break;

  case IR_VC_ZERO_INITIALIZER:
    len += addstr(dstp, "zeroinitializer");
    break;

  case IR_VC_REGFRAME:
    len += addstr(dstp, "(");
    len += type_print(dstp, iu, it);
    snprintf(tmpbuf, sizeof(tmpbuf), ")%%%d{0x%x}", value, iv->iv_reg);
    len += addstr(dstp, tmpbuf);
    break;
  case IR_VC_MACHINEREG:
    len += addstr(dstp, "(");
    len += type_print(dstp, iu, it);
    snprintf(tmpbuf, sizeof(tmpbuf), ")%%%d{r%d}", value, iv->iv_reg);
    len += addstr(dstp, tmpbuf);
    break;
  case IR_VC_DATA:
    {
      len += addstr(dstp, "data [");
      int size = type_sizeof(iu, iv->iv_type);
      for(int i = 0; i < size; i++) {
        if(i)
          len += addstr(dstp, ".");
        snprintf(tmpbuf, sizeof(tmpbuf), "%02x", ((uint8_t *)iv->iv_data)[i]);
        len += addstr(dstp, tmpbuf);
      }
      len += addstr(dstp, "]");
    }
    break;
  }

  if(iv->iv_name != NULL) {
    len += addstr(dstp, "\"");
    len += addstr(dstp, iv->iv_name);
    len += addstr(dstp, "\"");
  }
  return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
testq %rcx, %rcx
jne 0xfa75
movslq 0x24(%r14), %rax
cmpq %rax, 0x170(%r12)
jbe 0xfa72
leaq (%rax,%rax,4), %r13
shlq $0x3, %r13
addq 0x168(%r12), %r13
jmp 0xfa75
xorl %r13d, %r13d
movl (%r14), %eax
cmpq $0xc, %rax
ja 0xfe5f
movl 0x20(%r14), %ebp
leaq 0x1432b(%rip), %rcx     # 0x23db8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xb, %r15d
testq %rbx, %rbx
je 0xff91
movq (%rbx), %rax
movabsq $0x6e696665646e753c, %rcx # imm = 0x6E696665646E753C
movq %rcx, (%rax)
movl $0x3e64656e, 0x7(%rax)  # imm = 0x3E64656E
jmp 0xff0d
movl $0xf, %r15d
testq %rbx, %rbx
je 0xff91
movq (%rbx), %rax
movabsq $0x72657a696c616974, %rcx # imm = 0x72657A696C616974
movq %rcx, 0x7(%rax)
movabsq $0x74696e696f72657a, %rcx # imm = 0x74696E696F72657A
movq %rcx, (%rax)
addq $0xf, (%rbx)
jmp 0xff91
testq %rbx, %rbx
je 0xfb05
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %r15d
incl %r15d
leaq 0x1612c(%rip), %rdx     # 0x25c4c
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
jmp 0xff61
leaq 0x160de(%rip), %rdx     # 0x25c19
leaq 0x10(%rsp), %r15
movl $0x40, %esi
movq %r15, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31a0
movq %r15, %rdi
callq 0x3170
movq %rax, %r15
testq %rbx, %rbx
je 0xff91
movq (%rbx), %rdi
movslq %r15d, %r12
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x3360
addq %r12, (%rbx)
jmp 0xff91
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %ebp
testq %rbx, %rbx
je 0xfba2
movq (%rbx), %rax
movl $0x7b203d20, (%rax)     # imm = 0x7B203D20
addq $0x4, (%rbx)
addl $0x4, %ebp
cmpl $0x0, 0x30(%r14)
movq %r14, (%rsp)
jle 0xff13
movq 0x18(%r14), %r14
xorl %r13d, %r13d
testq %r13, %r13
je 0xfbd4
testq %rbx, %rbx
je 0xfbd1
movq (%rbx), %rax
movw $0x202c, (%rax)         # imm = 0x202C
addq $0x2, (%rbx)
addl $0x2, %ebp
movq (%r14,%r13,8), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1010e
movl %eax, %r15d
addl %ebp, %r15d
incq %r13
movq (%rsp), %rax
movslq 0x30(%rax), %rax
movl %r15d, %ebp
cmpq %rax, %r13
jl 0xfbbb
jmp 0xff16
testq %rbx, %rbx
je 0xfc1a
movq (%rbx), %rax
movl $0x206c6162, 0x3(%rax)  # imm = 0x206C6162
movl $0x626f6c67, (%rax)     # imm = 0x626F6C67
addq $0x7, (%rbx)
movq 0x30(%r14), %rax
movq 0x20(%rax), %r15
testq %r15, %r15
je 0xff2d
movq %r15, %rdi
callq 0x3170
movq %rax, %rbp
testq %rbx, %rbx
je 0xfc61
movq (%rbx), %rdi
movslq %ebp, %rax
movq %r15, %rsi
movq %rax, %r15
movq %rax, %rdx
callq 0x3360
movq (%rbx), %rax
leaq (%rax,%r15), %rcx
movq %rcx, (%rbx)
movb $0x20, (%rax,%r15)
incq (%rbx)
addl $0x8, %ebp
jmp 0xff32
testq %rbx, %rbx
je 0xfc77
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %r15d
incl %r15d
leaq 0x15fba(%rip), %rdx     # 0x25c4c
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31a0
movq %r12, %rdi
callq 0x3170
testq %rbx, %rbx
je 0x10007
movq (%rbx), %rdi
movslq %eax, %r12
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x3360
movq (%rbx), %rax
addq %r12, %rax
movq %rax, (%rbx)
addl %r12d, %r15d
testq %r13, %r13
jne 0x1000f
movl $0x65707974, 0x3(%rax)  # imm = 0x65707974
movl $0x74646162, (%rax)     # imm = 0x74646162
addq $0x7, (%rbx)
jmp 0x10050
testq %rbx, %rbx
je 0xfd0f
movq (%rbx), %rax
movw $0x5b20, 0x4(%rax)      # imm = 0x5B20
movl $0x61746164, (%rax)     # imm = 0x61746164
addq $0x6, (%rbx)
movl 0x24(%r14), %esi
movq %r12, %rdi
callq 0xf5f0
testl %eax, %eax
jle 0x10059
movq %r14, (%rsp)
movl %eax, %eax
movq %rax, 0x8(%rsp)
movl $0x6, %r15d
leaq 0x10(%rsp), %r13
xorl %r14d, %r14d
testq %r14, %r14
je 0xfd52
testq %rbx, %rbx
je 0xfd4f
movq (%rbx), %rax
movb $0x2e, (%rax)
incq (%rbx)
incl %r15d
movq (%rsp), %rax
movq 0x18(%rax), %rax
movzbl (%rax,%r14), %ecx
movl $0x40, %esi
movq %r13, %rdi
leaq 0x15f31(%rip), %rdx     # 0x25c9f
xorl %eax, %eax
callq 0x31a0
movq %r13, %rdi
callq 0x3170
movq %rax, %rbp
testq %rbx, %rbx
je 0xfd99
movq (%rbx), %rdi
movslq %ebp, %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0x3360
addq %r12, (%rbx)
addl %ebp, %r15d
incq %r14
cmpq %r14, 0x8(%rsp)
jne 0xfd3c
incl %r15d
movq (%rsp), %r14
jmp 0x1005f
movq %r12, 0x8(%rsp)
testq %rbx, %rbx
je 0xfdd4
movq (%rbx), %rax
movabsq $0x6e6f6974636e7566, %rcx # imm = 0x6E6F6974636E7566
movq %rcx, (%rax)
movb $0x20, 0x8(%rax)
addq $0x9, (%rbx)
movq %r14, %r12
movq 0x30(%r14), %r14
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x10076
movq %r15, %rdi
callq 0x3170
movq %rax, %r13
testq %rbx, %rbx
je 0xfe27
movq (%rbx), %rdi
movslq %r13d, %rbp
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3360
movq (%rbx), %rax
leaq (%rax,%rbp), %rcx
movq %rcx, (%rbx)
movb $0x20, 0x2(%rax,%rbp)
movw $0x2928, (%rax,%rbp)    # imm = 0x2928
addq $0x3, (%rbx)
movq 0x30(%r12), %r14
addl $0xc, %r13d
jmp 0x1007c
testq %rbx, %rbx
je 0xfe3e
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %r15d
incl %r15d
movl 0x30(%r14), %r8d
leaq 0x15e24(%rip), %rdx     # 0x25c81
jmp 0xfe94
xorl %r15d, %r15d
jmp 0xff91
testq %rbx, %rbx
je 0xfe75
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %r15d
incl %r15d
movl 0x30(%r14), %r8d
leaq 0x15df9(%rip), %rdx     # 0x25c8d
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31a0
jmp 0xff68
testq %rbx, %rbx
je 0xfecc
movq (%rbx), %rax
movabsq $0x3e2d207361696c61, %rcx # imm = 0x3E2D207361696C61
movq %rcx, (%rax)
movb $0x20, 0x8(%rax)
addq $0x9, (%rbx)
movl 0x30(%r14), %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf9b4
movl %eax, %r15d
addl $0x9, %r15d
jmp 0xff91
movl $0xb, %r15d
testq %rbx, %rbx
je 0xff91
movq (%rbx), %rax
movabsq $0x786574736e6f633c, %rcx # imm = 0x786574736E6F633C
movq %rcx, (%rax)
movl $0x3e727078, 0x7(%rax)  # imm = 0x3E727078
addq $0xb, (%rbx)
jmp 0xff91
movl %ebp, %r15d
testq %rbx, %rbx
je 0xff24
movq (%rbx), %rax
movb $0x7d, (%rax)
incq (%rbx)
incl %r15d
movq (%rsp), %r14
jmp 0xff91
movl $0x7, %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xcebd
movl %eax, %r15d
addl %ebp, %r15d
movq 0x30(%r14), %rax
movl 0x28(%rax), %ecx
leaq 0x15cf0(%rip), %rdx     # 0x25c44
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x31a0
movq %r12, %rdi
callq 0x3170
movq %rax, %r12
testq %rbx, %rbx
je 0xff8e
movq (%rbx), %rdi
movslq %r12d, %r13
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x3360
addq %r13, (%rbx)
addl %r12d, %r15d
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0xfff5
testq %rbx, %rbx
je 0xffe7
movq (%rbx), %rax
movb $0x22, %bpl
movb %bpl, (%rax)
movq (%rbx), %r12
incq %r12
movq %r12, (%rbx)
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x3170
movslq %eax, %r13
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x3360
movq (%rbx), %rax
leaq (%rax,%r13), %rcx
movq %rcx, (%rbx)
addl %r13d, %r15d
incl %r15d
movb %bpl, (%rax,%r13)
incq (%rbx)
jmp 0xfff2
callq 0x3170
addl %eax, %r15d
incl %r15d
incl %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl %eax, %r15d
testq %r13, %r13
je 0x10050
movl (%r13), %ecx
leal -0x2(%rcx), %eax
cmpl $0x9, %eax
ja 0x100f8
leaq 0x13dc6(%rip), %rdx     # 0x23dec
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x30(%r14), %ecx
leaq 0x15ec4(%rip), %rdx     # 0x25efe
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0x31a0
jmp 0x100ee
addl $0x7, %r15d
jmp 0xff91
movl $0x7, %r15d
testq %rbx, %rbx
je 0xff91
movq (%rbx), %rax
movb $0x5d, (%rax)
incq (%rbx)
jmp 0xff91
movl $0x9, %r13d
movl 0x10(%r14), %edx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xd2e5
movl %eax, %r15d
addl %r13d, %r15d
movq %r12, %r14
jmp 0xff91
movq 0x30(%r14), %rcx
leaq 0x15bb4(%rip), %rdx     # 0x25c5a
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0x31a0
jmp 0x100ee
xorl %ecx, %ecx
cmpl $0x0, 0x30(%r14)
setne %cl
jmp 0x10033
cvtss2sd 0x30(%r14), %xmm0
jmp 0x100d6
movsd 0x30(%r14), %xmm0
leaq 0x15b84(%rip), %rdx     # 0x25c61
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
movb $0x1, %al
callq 0x31a0
leaq 0x10(%rsp), %rdi
jmp 0xff6b
leaq 0x15b66(%rip), %rdx     # 0x25c65
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
jmp 0x10044