// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::DataTypeApplyOpFromText(char const*, char const*, int, void*, char const*)
bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format)
{
    while (ImCharIsBlankA(*buf))
        buf++;

    // We don't support '-' op because it would conflict with inputing negative value.
    // Instead you can use +-100 to subtract from an existing value
    char op = buf[0];
    if (op == '+' || op == '*' || op == '/')
    {
        buf++;
        while (ImCharIsBlankA(*buf))
            buf++;
    }
    else
    {
        op = 0;
    }
    if (!buf[0])
        return false;

    // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
    const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
    ImGuiDataTypeTempStorage data_backup;
    memcpy(&data_backup, p_data, type_info->Size);

    if (format == NULL)
        format = type_info->ScanFmt;

    // FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point..
    int arg1i = 0;
    if (data_type == ImGuiDataType_S32)
    {
        int* v = (int*)p_data;
        int arg0i = *v;
        float arg1f = 0.0f;
        if (op && sscanf(initial_value_buf, format, &arg0i) < 1)
            return false;
        // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
        if (op == '+')      { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); }                   // Add (use "+-" to subtract)
        else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); }                   // Multiply
        else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); }  // Divide
        else                { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; }                           // Assign constant
    }
    else if (data_type == ImGuiDataType_Float)
    {
        // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
        format = "%f";
        float* v = (float*)p_data;
        float arg0f = *v, arg1f = 0.0f;
        if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
            return false;
        if (sscanf(buf, format, &arg1f) < 1)
            return false;
        if (op == '+')      { *v = arg0f + arg1f; }                    // Add (use "+-" to subtract)
        else if (op == '*') { *v = arg0f * arg1f; }                    // Multiply
        else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
        else                { *v = arg1f; }                            // Assign constant
    }
    else if (data_type == ImGuiDataType_Double)
    {
        format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis
        double* v = (double*)p_data;
        double arg0f = *v, arg1f = 0.0;
        if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
            return false;
        if (sscanf(buf, format, &arg1f) < 1)
            return false;
        if (op == '+')      { *v = arg0f + arg1f; }                    // Add (use "+-" to subtract)
        else if (op == '*') { *v = arg0f * arg1f; }                    // Multiply
        else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
        else                { *v = arg1f; }                            // Assign constant
    }
    else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
    {
        // All other types assign constant
        // We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future.
        sscanf(buf, format, p_data);
    }
    else
    {
        // Small types need a 32-bit buffer to receive the result from scanf()
        int v32;
        sscanf(buf, format, &v32);
        if (data_type == ImGuiDataType_S8)
            *(ImS8*)p_data = (ImS8)ImClamp(v32, (int)IM_S8_MIN, (int)IM_S8_MAX);
        else if (data_type == ImGuiDataType_U8)
            *(ImU8*)p_data = (ImU8)ImClamp(v32, (int)IM_U8_MIN, (int)IM_U8_MAX);
        else if (data_type == ImGuiDataType_S16)
            *(ImS16*)p_data = (ImS16)ImClamp(v32, (int)IM_S16_MIN, (int)IM_S16_MAX);
        else if (data_type == ImGuiDataType_U16)
            *(ImU16*)p_data = (ImU16)ImClamp(v32, (int)IM_U16_MIN, (int)IM_U16_MAX);
        else
            IM_ASSERT(0);
    }

    return memcmp(&data_backup, p_data, type_info->Size) != 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r12
movq %rcx, -0x40(%rbp)
movl %edx, %r14d
movq %rsi, %r13
movq %rdi, %r15
movabsq $0x100000200, %rax      # imm = 0x100000200
movzbl (%r15), %ebx
cmpq $0x2f, %rbx
ja 0x7e346
btq %rbx, %rax
jae 0x7e323
incq %r15
jmp 0x7e30e
movabsq $0x8c0000000000, %rax   # imm = 0x8C0000000000
btq %rbx, %rax
jae 0x7e346
incq %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0x7e333
cmpl $0x9, %eax
je 0x7e333
jmp 0x7e34a
movl %ebx, %eax
xorl %ebx, %ebx
testb %al, %al
je 0x7e4fe
movl %r14d, %edi
callq 0x7ddfc
movq %rax, -0x50(%rbp)
movq (%rax), %rdx
leaq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xc080
testq %r12, %r12
jne 0x7e37b
movq -0x50(%rbp), %rax
movq 0x18(%rax), %r12
andl $0x0, -0x44(%rbp)
cmpl $0x9, %r14d
je 0x7e489
cmpl $0x8, %r14d
je 0x7e40d
cmpl $0x4, %r14d
jne 0x7e505
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
andl $0x0, -0x38(%rbp)
testb %bl, %bl
je 0x7e569
leaq -0x30(%rbp), %rdx
movq %r13, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
jle 0x7e4fe
cmpb $0x2a, %bl
je 0x7e692
movzbl %bl, %eax
cmpl $0x2f, %eax
je 0x7e65b
cmpl $0x2b, %eax
jne 0x7e569
leaq 0x25396(%rip), %rsi     # 0xa3782
leaq -0x44(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
je 0x7e6bf
movl -0x44(%rbp), %eax
addl -0x30(%rbp), %eax
jmp 0x7e6b9
movq -0x40(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x30(%rbp)
andl $0x0, -0x38(%rbp)
testb %bl, %bl
je 0x7e43f
leaq 0x283f0(%rip), %rsi     # 0xa6819
leaq -0x30(%rbp), %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
jle 0x7e4fe
leaq 0x283d3(%rip), %rsi     # 0xa6819
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
jle 0x7e4fe
cmpb $0x2a, %bl
je 0x7e605
movzbl %bl, %eax
cmpl $0x2f, %eax
je 0x7e5e7
cmpl $0x2b, %eax
jne 0x7e631
movss -0x30(%rbp), %xmm0
addss -0x38(%rbp), %xmm0
jmp 0x7e636
movq -0x40(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
andq $0x0, -0x38(%rbp)
testb %bl, %bl
je 0x7e4b8
leaq 0x3a4d9(%rip), %rsi     # 0xb897f
leaq -0x30(%rbp), %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
jle 0x7e4fe
leaq 0x3a4c0(%rip), %rsi     # 0xb897f
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
jle 0x7e4fe
cmpb $0x2a, %bl
je 0x7e640
movzbl %bl, %eax
cmpl $0x2f, %eax
je 0x7e611
cmpl $0x2b, %eax
jne 0x7e64c
movsd -0x30(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
jmp 0x7e651
xorl %eax, %eax
jmp 0x7e6d8
leal -0x5(%r14), %eax
cmpl $0x2, %eax
ja 0x7e524
movq %r15, %rdi
movq %r12, %rsi
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0xc0c0
jmp 0x7e6bf
leaq -0x30(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xc0c0
cmpl $0x3, %r14d
ja 0x7e6e7
movl %r14d, %eax
leaq 0x39c97(%rip), %rcx     # 0xb81e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x30(%rbp), %eax
cmpl $0x7f, %eax
pushq $0x7f
popq %rcx
cmovll %eax, %ecx
cmpl $-0x7f, %ecx
pushq $-0x80
popq %rax
cmovgel %ecx, %eax
jmp 0x7e5dc
leaq -0x44(%rbp), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xc0c0
cmpl $0x1, %eax
jne 0x7e6bf
movl -0x44(%rbp), %eax
jmp 0x7e6b9
movl -0x30(%rbp), %eax
movl $0x7fff, %ecx           # imm = 0x7FFF
cmpl %ecx, %eax
cmovll %eax, %ecx
cmpl $0xffff8001, %ecx       # imm = 0xFFFF8001
movl $0xffff8000, %eax       # imm = 0xFFFF8000
cmovgel %ecx, %eax
jmp 0x7e5bc
movl -0x30(%rbp), %eax
movl $0xffff, %ecx           # imm = 0xFFFF
cmpl %ecx, %eax
cmovll %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
movq -0x40(%rbp), %rcx
movw %ax, (%rcx)
jmp 0x7e6bf
movl -0x30(%rbp), %eax
movl $0xff, %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
movq -0x40(%rbp), %rcx
movb %al, (%rcx)
jmp 0x7e6bf
movss -0x38(%rbp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x7e5fa
jnp 0x7e6bf
movss -0x30(%rbp), %xmm0
divss %xmm1, %xmm0
jmp 0x7e636
movss -0x30(%rbp), %xmm0
mulss -0x38(%rbp), %xmm0
jmp 0x7e636
movsd -0x38(%rbp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x7e626
jnp 0x7e6bf
movsd -0x30(%rbp), %xmm0
divsd %xmm1, %xmm0
jmp 0x7e651
movss -0x38(%rbp), %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
jmp 0x7e6bf
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
jmp 0x7e651
movsd -0x38(%rbp), %xmm0
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x7e6bf
leaq 0x281b7(%rip), %rsi     # 0xa6819
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
je 0x7e6bf
movss -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x7e683
jnp 0x7e6bf
cvtsi2ssl -0x30(%rbp), %xmm1
divss %xmm0, %xmm1
cvttss2si %xmm1, %eax
jmp 0x7e6b9
leaq 0x28180(%rip), %rsi     # 0xa6819
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0xc0c0
testl %eax, %eax
je 0x7e6bf
cvtsi2ssl -0x30(%rbp), %xmm0
mulss -0x38(%rbp), %xmm0
cvttss2si %xmm0, %eax
movq -0x40(%rbp), %rcx
movl %eax, (%rcx)
movq -0x50(%rbp), %rax
movq (%rax), %rdx
leaq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xc5f0
testl %eax, %eax
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20a2e(%rip), %rdi     # 0x9f11c
leaq 0x39c93(%rip), %rsi     # 0xb8388
leaq 0x3a287(%rip), %rcx     # 0xb8983
movl $0x7b9, %edx            # imm = 0x7B9
callq 0xc140