// File: /workspace/github_cpp_makefile_star2_O1/donfreiday[P]gb/./imgui/imgui.cpp
// Function: DataTypeApplyOpFromText(char const*, char const*, ImGuiDataType, void*, char const*)
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
{
    while (ImCharIsSpace(*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 (ImCharIsSpace(*buf))
            buf++;
    }
    else
    {
        op = 0;
    }
    if (!buf[0])
        return;

    if (data_type == ImGuiDataType_Int)
    {
        if (!scalar_format)
            scalar_format = "%d";
        int* v = (int*)data_ptr;
        int ref_v = *v;
        if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
            return;

        // 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
        float op_v = 0.0f;
        if (op == '+')      { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v + op_v); }                // Add (use "+-" to subtract)
        else if (op == '*') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v * op_v); }                // Multiply
        else if (op == '/') { if (sscanf(buf, "%f", &op_v) == 1 && op_v != 0.0f) *v = (int)(ref_v / op_v); }// Divide
        else                { if (sscanf(buf, scalar_format, &ref_v) == 1) *v = ref_v; }                    // Assign constant
    }
    else if (data_type == ImGuiDataType_Float)
    {
        if (!scalar_format)
            scalar_format = "%f";
        float* v = (float*)data_ptr;
        float ref_v = *v;
        if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
            return;
        float op_v = 0.0f;
        if (sscanf(buf, scalar_format, &op_v) < 1)
            return;

        if (op == '+')      { *v = ref_v + op_v; }                      // Add (use "+-" to subtract)
        else if (op == '*') { *v = ref_v * op_v; }                      // Multiply
        else if (op == '/') { if (op_v != 0.0f) *v = ref_v / op_v; }    // Divide
        else                { *v = op_v; }                              // Assign constant
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdi, %r14
movabsq $0x100000200, %rax      # imm = 0x100000200
movzbl (%r14), %r12d
cmpq $0x2f, %r12
ja 0x1a7a3
btq %r12, %rax
jae 0x1a780
incq %r14
jmp 0x1a76b
movabsq $0x8c0000000000, %rax   # imm = 0x8C0000000000
btq %r12, %rax
jae 0x1a7a3
incq %r14
movzbl (%r14), %eax
cmpl $0x20, %eax
je 0x1a790
cmpl $0x9, %eax
je 0x1a790
jmp 0x1a7a6
xorl %r12d, %r12d
cmpb $0x0, (%r14)
je 0x1a982
cmpl $0x1, %edx
je 0x1a846
testl %edx, %edx
jne 0x1a982
testq %r8, %r8
leaq 0x240bc(%rip), %r15     # 0x3e887
cmovneq %r8, %r15
movl (%rbx), %eax
movl %eax, -0x28(%rbp)
testb %r12b, %r12b
je 0x1a7f2
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a982
movl $0x0, -0x24(%rbp)
cmpb $0x2a, %r12b
je 0x1a90c
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x1a8c9
cmpl $0x2b, %eax
jne 0x1a936
leaq 0x25570(%rip), %rsi     # 0x3fd90
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a982
cvtsi2ssl -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x1a930
testq %r8, %r8
leaq 0x25540(%rip), %r15     # 0x3fd90
cmovneq %r8, %r15
movss (%rbx), %xmm0
movss %xmm0, -0x28(%rbp)
testb %r12b, %r12b
je 0x1a87b
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a982
leaq -0x24(%rbp), %rdx
movl $0x0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a982
cmpb $0x2a, %r12b
je 0x1a96d
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x1a953
cmpl $0x2b, %eax
jne 0x1a979
movss -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x1a97e
leaq 0x254c0(%rip), %rsi     # 0x3fd90
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a982
movss -0x24(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1a8fa
jnp 0x1a982
xorps %xmm1, %xmm1
cvtsi2ssl -0x28(%rbp), %xmm1
divss %xmm0, %xmm1
cvttss2si %xmm1, %eax
jmp 0x1a94f
leaq 0x2547d(%rip), %rsi     # 0x3fd90
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a982
cvtsi2ssl -0x28(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
cvttss2si %xmm0, %eax
jmp 0x1a94f
leaq -0x28(%rbp), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a982
movl -0x28(%rbp), %eax
movl %eax, (%rbx)
jmp 0x1a982
movss -0x24(%rbp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x1a962
jnp 0x1a982
movss -0x28(%rbp), %xmm0
divss %xmm1, %xmm0
jmp 0x1a97e
movss -0x28(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
jmp 0x1a97e
movss -0x24(%rbp), %xmm0
movss %xmm0, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq