// File: bluesky466[P]ResourcesArscDemo/main.cpp
// Function: printStringOfComplex(unsigned int, bool)
void printStringOfComplex(uint32_t complex, bool isFraction) {
    const float MANTISSA_MULT =
        1.0f / (1<<Res_value::COMPLEX_MANTISSA_SHIFT);
    const float RADIX_MULTS[] = {
        1.0f*MANTISSA_MULT, 1.0f/(1<<7)*MANTISSA_MULT,
        1.0f/(1<<15)*MANTISSA_MULT, 1.0f/(1<<23)*MANTISSA_MULT
    };

    float value = (complex&(Res_value::COMPLEX_MANTISSA_MASK
                   <<Res_value::COMPLEX_MANTISSA_SHIFT))
            * RADIX_MULTS[(complex>>Res_value::COMPLEX_RADIX_SHIFT)
                            & Res_value::COMPLEX_RADIX_MASK];
	printf("%f",value);

    if (!isFraction) {
        switch ((complex>>Res_value::COMPLEX_UNIT_SHIFT)&Res_value::COMPLEX_UNIT_MASK) {
            case Res_value::COMPLEX_UNIT_PX: printf("px\n"); break;
            case Res_value::COMPLEX_UNIT_DIP: printf("dp\n"); break;
            case Res_value::COMPLEX_UNIT_SP: printf("sp\n"); break;
            case Res_value::COMPLEX_UNIT_PT: printf("pt\n"); break;
            case Res_value::COMPLEX_UNIT_IN: printf("in\n"); break;
            case Res_value::COMPLEX_UNIT_MM: printf("mm\n"); break;
            default: printf("(unknown unit)\n"); break;
        }
    } else {
        switch ((complex>>Res_value::COMPLEX_UNIT_SHIFT)&Res_value::COMPLEX_UNIT_MASK) {
            case Res_value::COMPLEX_UNIT_FRACTION: printf("%%\n"); break;
            case Res_value::COMPLEX_UNIT_FRACTION_PARENT: printf("%%p\n"); break;
            default: printf("(unknown unit)\n"); break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movl %edi, -0x4(%rbp)
andb $0x1, %al
movb %al, -0x5(%rbp)
movl $0x3b800000, -0xc(%rbp) # imm = 0x3B800000
movaps 0x62ff(%rip), %xmm0     # 0x9370
movaps %xmm0, -0x20(%rbp)
movl -0x4(%rbp), %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cvtsi2ss %rax, %xmm0
movl -0x4(%rbp), %eax
shrl $0x4, %eax
andl $0x3, %eax
movl %eax, %eax
mulss -0x20(%rbp,%rax,4), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x61cf(%rip), %rdi      # 0x9277
movb $0x1, %al
callq 0x2030
testb $0x1, -0x5(%rbp)
jne 0x314e
movl -0x4(%rbp), %eax
andl $0xf, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x5, %eax
ja 0x313e
movq -0x30(%rbp), %rax
leaq 0x5f2f(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x6195(%rip), %rdi      # 0x927a
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x6189(%rip), %rdi      # 0x927e
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x617d(%rip), %rdi      # 0x9282
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x6171(%rip), %rdi      # 0x9286
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x6165(%rip), %rdi      # 0x928a
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x6159(%rip), %rdi      # 0x928e
movb $0x0, %al
callq 0x2030
jmp 0x314c
leaq 0x614d(%rip), %rdi      # 0x9292
movb $0x0, %al
callq 0x2030
jmp 0x3195
movl -0x4(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x34(%rbp)
je 0x3165
jmp 0x315b
movl -0x34(%rbp), %eax
subl $0x1, %eax
je 0x3175
jmp 0x3185
leaq 0x6136(%rip), %rdi      # 0x92a2
movb $0x0, %al
callq 0x2030
jmp 0x3193
leaq 0x612a(%rip), %rdi      # 0x92a6
movb $0x0, %al
callq 0x2030
jmp 0x3193
leaq 0x6106(%rip), %rdi      # 0x9292
movb $0x0, %al
callq 0x2030
jmp 0x3195
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)