// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a3d8
btq %r12, %rax
jae 0x1a3b5
incq %r14
jmp 0x1a3a0
movabsq $0x8c0000000000, %rax   # imm = 0x8C0000000000
btq %r12, %rax
jae 0x1a3d8
incq %r14
movzbl (%r14), %eax
cmpl $0x20, %eax
je 0x1a3c5
cmpl $0x9, %eax
je 0x1a3c5
jmp 0x1a3de
movl %r12d, %eax
xorl %r12d, %r12d
testb %al, %al
je 0x1a5b7
cmpl $0x1, %edx
je 0x1a480
testl %edx, %edx
jne 0x1a5b7
testq %r8, %r8
leaq 0x244b6(%rip), %r15     # 0x3e8b7
cmovneq %r8, %r15
movl (%rbx), %eax
movl %eax, -0x28(%rbp)
testb %r12b, %r12b
je 0x1a4f4
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a5b7
movl $0x0, -0x24(%rbp)
cmpb $0x2a, %r12b
je 0x1a58d
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x1a552
cmpl $0x2b, %eax
jne 0x1a4fb
leaq 0x258b6(%rip), %rsi     # 0x3fd10
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a5b7
cvtsi2ssl -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x1a5b1
testq %r8, %r8
leaq 0x25886(%rip), %r15     # 0x3fd10
cmovneq %r8, %r15
movss (%rbx), %xmm0
movss %xmm0, -0x28(%rbp)
testb %r12b, %r12b
je 0x1a4b5
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a5b7
leaq -0x24(%rbp), %rdx
movl $0x0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1a5b7
cmpb $0x2a, %r12b
je 0x1a53b
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x1a51d
cmpl $0x2b, %eax
jne 0x1a547
movss -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x1a54c
movl $0x0, -0x24(%rbp)
leaq -0x28(%rbp), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a5b7
movl -0x28(%rbp), %eax
jmp 0x1a5b5
movss -0x24(%rbp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x1a530
jnp 0x1a5b7
movss -0x28(%rbp), %xmm0
divss %xmm1, %xmm0
jmp 0x1a54c
movss -0x28(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
jmp 0x1a54c
movss -0x24(%rbp), %xmm0
movss %xmm0, (%rbx)
jmp 0x1a5b7
leaq 0x257b7(%rip), %rsi     # 0x3fd10
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a5b7
movss -0x24(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1a57b
jnp 0x1a5b7
xorps %xmm1, %xmm1
cvtsi2ssl -0x28(%rbp), %xmm1
divss %xmm0, %xmm1
cvttss2si %xmm1, %eax
jmp 0x1a5b5
leaq 0x2577c(%rip), %rsi     # 0x3fd10
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1a5b7
cvtsi2ssl -0x28(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq