// File: /workspace/github_c_makefile_star2_O1/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 0xfb27
movslq 0x24(%r14), %rax
cmpq %rax, 0x170(%r12)
jbe 0xfb24
leaq (%rax,%rax,4), %r13
shlq $0x3, %r13
addq 0x168(%r12), %r13
jmp 0xfb27
xorl %r13d, %r13d
movl (%r14), %eax
cmpq $0xc, %rax
ja 0xff2b
movl 0x20(%r14), %ebp
leaq 0x14255(%rip), %rcx     # 0x23d94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xb, %r15d
testq %rbx, %rbx
je 0x1005e
movq (%rbx), %rax
movabsq $0x6e696665646e753c, %rcx # imm = 0x6E696665646E753C
movq %rcx, (%rax)
movl $0x3e64656e, 0x7(%rax)  # imm = 0x3E64656E
jmp 0xffd9
movl $0xf, %r15d
testq %rbx, %rbx
je 0x1005e
movq (%rbx), %rax
movabsq $0x72657a696c616974, %rcx # imm = 0x72657A696C616974
movq %rcx, 0x7(%rax)
movabsq $0x74696e696f72657a, %rcx # imm = 0x74696E696F72657A
movq %rcx, (%rax)
addq $0xf, (%rbx)
jmp 0x1005e
testq %rbx, %rbx
je 0xfbb7
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %r15d
incl %r15d
leaq 0x15fca(%rip), %rdx     # 0x25b9c
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
jmp 0x1002e
leaq 0x15f7c(%rip), %rdx     # 0x25b69
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 0x1005e
movq (%rbx), %rdi
movslq %r15d, %r12
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x3360
addq %r12, (%rbx)
jmp 0x1005e
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %ebp
testq %rbx, %rbx
je 0xfc54
movq (%rbx), %rax
movl $0x7b203d20, (%rax)     # imm = 0x7B203D20
addq $0x4, (%rbx)
addl $0x4, %ebp
cmpl $0x0, 0x30(%r14)
movq %r14, 0x8(%rsp)
jle 0xffdf
movq 0x18(%r14), %r14
xorl %r13d, %r13d
testq %r13, %r13
je 0xfc87
testq %rbx, %rbx
je 0xfc84
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 0x10197
movl %eax, %r15d
addl %ebp, %r15d
incq %r13
movq 0x8(%rsp), %rax
movslq 0x30(%rax), %rax
movl %r15d, %ebp
cmpq %rax, %r13
jl 0xfc6e
jmp 0xffe2
testq %rbx, %rbx
je 0xfcce
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 0xfffa
movq %r15, %rdi
callq 0x3170
movq %rax, %rbp
testq %rbx, %rbx
je 0xfd06
movq (%rbx), %rdi
movslq %ebp, %rax
movq %r15, %rsi
movq %rax, %r15
movq %rax, %rdx
callq 0x3360
addq %r15, (%rbx)
testq %rbx, %rbx
je 0xfd14
movq (%rbx), %rax
movb $0x20, (%rax)
incq (%rbx)
addl $0x8, %ebp
jmp 0xffff
testq %rbx, %rbx
je 0xfd2a
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %r15d
incl %r15d
leaq 0x15e57(%rip), %rdx     # 0x25b9c
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31a0
movq %r12, %rdi
callq 0x3170
movq %rax, %r12
testq %rbx, %rbx
je 0xfd81
movq (%rbx), %rdi
movslq %r12d, %rbp
leaq 0x10(%rsp), %rsi
movq %rbp, %rdx
callq 0x3360
addq %rbp, (%rbx)
addl %r12d, %r15d
testq %r13, %r13
je 0x100c2
movl (%r13), %ecx
leal -0x2(%rcx), %eax
cmpl $0x9, %eax
ja 0x10181
leaq 0x14024(%rip), %rdx     # 0x23dc8
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x30(%r14), %ecx
leaq 0x160fc(%rip), %rdx     # 0x25eb4
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0x31a0
jmp 0x10177
testq %rbx, %rbx
je 0xfde6
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 0xf67c
testl %eax, %eax
jle 0x100e4
movq %r14, 0x8(%rsp)
movl %eax, %eax
movq %rax, 0x50(%rsp)
movl $0x6, %r15d
leaq 0x10(%rsp), %r13
xorl %r14d, %r14d
testq %r14, %r14
je 0xfe2a
testq %rbx, %rbx
je 0xfe27
movq (%rbx), %rax
movb $0x2e, (%rax)
incq (%rbx)
incl %r15d
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movzbl (%rax,%r14), %ecx
movl $0x40, %esi
movq %r13, %rdi
leaq 0x15da8(%rip), %rdx     # 0x25bef
xorl %eax, %eax
callq 0x31a0
movq %r13, %rdi
callq 0x3170
movq %rax, %rbp
testq %rbx, %rbx
je 0xfe72
movq (%rbx), %rdi
movslq %ebp, %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0x3360
addq %r12, (%rbx)
addl %ebp, %r15d
incq %r14
cmpq %r14, 0x50(%rsp)
jne 0xfe14
incl %r15d
movq 0x8(%rsp), %r14
jmp 0x100ea
testq %rbx, %rbx
je 0xfea9
movq (%rbx), %rax
movabsq $0x6e6f6974636e7566, %rcx # imm = 0x6E6F6974636E7566
movq %rcx, (%rax)
movb $0x20, 0x8(%rax)
addq $0x9, (%rbx)
movq 0x30(%r14), %rax
movq 0x20(%rax), %r15
testq %r15, %r15
je 0x10101
movq %r15, %rdi
callq 0x3170
movq %rax, %r13
testq %rbx, %rbx
je 0xfede
movq (%rbx), %rdi
movslq %r13d, %rbp
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3360
addq %rbp, (%rbx)
testq %rbx, %rbx
je 0xfef3
movq (%rbx), %rax
movb $0x20, 0x2(%rax)
movw $0x2928, (%rax)         # imm = 0x2928
addq $0x3, (%rbx)
addl $0xc, %r13d
jmp 0x10107
testq %rbx, %rbx
je 0xff0a
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %r15d
incl %r15d
movl 0x30(%r14), %r8d
leaq 0x15ca8(%rip), %rdx     # 0x25bd1
jmp 0xff60
xorl %r15d, %r15d
jmp 0x1005e
testq %rbx, %rbx
je 0xff41
movq (%rbx), %rax
movb $0x28, (%rax)
incq (%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %r15d
incl %r15d
movl 0x30(%r14), %r8d
leaq 0x15c7d(%rip), %rdx     # 0x25bdd
leaq 0x10(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31a0
jmp 0x10035
testq %rbx, %rbx
je 0xff98
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 0xfa66
movl %eax, %r15d
addl $0x9, %r15d
jmp 0x1005e
movl $0xb, %r15d
testq %rbx, %rbx
je 0x1005e
movq (%rbx), %rax
movabsq $0x786574736e6f633c, %rcx # imm = 0x786574736E6F633C
movq %rcx, (%rax)
movl $0x3e727078, 0x7(%rax)  # imm = 0x3E727078
addq $0xb, (%rbx)
jmp 0x1005e
movl %ebp, %r15d
testq %rbx, %rbx
je 0xfff0
movq (%rbx), %rax
movb $0x7d, (%rax)
incq (%rbx)
incl %r15d
movq 0x8(%rsp), %r14
jmp 0x1005e
movl $0x7, %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xce99
movl %eax, %r15d
addl %ebp, %r15d
movq 0x30(%r14), %rax
movl 0x28(%rax), %ecx
leaq 0x15b73(%rip), %rdx     # 0x25b94
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 0x1005b
movq (%rbx), %rdi
movslq %r12d, %r13
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x3360
addq %r13, (%rbx)
addl %r12d, %r15d
cmpq $0x0, 0x10(%r14)
je 0x100b0
testq %rbx, %rbx
je 0x10073
movq (%rbx), %rax
movb $0x22, (%rax)
incq (%rbx)
movq 0x10(%r14), %r12
movq %r12, %rdi
callq 0x3170
movq %rax, %r14
testq %rbx, %rbx
je 0x1009b
movq (%rbx), %rdi
movslq %r14d, %r13
movq %r12, %rsi
movq %r13, %rdx
callq 0x3360
addq %r13, (%rbx)
testq %rbx, %rbx
je 0x100a9
movq (%rbx), %rax
movb $0x22, (%rax)
incq (%rbx)
addl %r14d, %r15d
addl $0x2, %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x100db
movq (%rbx), %rax
movl $0x65707974, 0x3(%rax)  # imm = 0x65707974
movl $0x74646162, (%rax)     # imm = 0x74646162
addq $0x7, (%rbx)
addl $0x7, %r15d
jmp 0x1005e
movl $0x7, %r15d
testq %rbx, %rbx
je 0x1005e
movq (%rbx), %rax
movb $0x5d, (%rax)
incq (%rbx)
jmp 0x1005e
movl $0x9, %r13d
movq 0x30(%r14), %rax
movl 0x10(%rax), %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2c1
movl %eax, %r15d
addl %r13d, %r15d
jmp 0x1005e
movq 0x30(%r14), %rcx
leaq 0x15a7b(%rip), %rdx     # 0x25baa
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0x31a0
jmp 0x10177
xorl %ecx, %ecx
cmpl $0x0, 0x30(%r14)
setne %cl
jmp 0xfdb1
cvtss2sd 0x30(%r14), %xmm0
jmp 0x1015f
movsd 0x30(%r14), %xmm0
leaq 0x15a4b(%rip), %rdx     # 0x25bb1
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
movb $0x1, %al
callq 0x31a0
leaq 0x10(%rsp), %rdi
jmp 0x10038
leaq 0x15a2d(%rip), %rdx     # 0x25bb5
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
jmp 0xfdc2