// File: /workspace/github_cpp_makefile_star2_O2/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 0x15eb7
btq %r12, %rax
jae 0x15e94
incq %r14
jmp 0x15e7f
movabsq $0x8c0000000000, %rax   # imm = 0x8C0000000000
btq %r12, %rax
jae 0x15eb7
incq %r14
movzbl (%r14), %eax
cmpl $0x20, %eax
je 0x15ea4
cmpl $0x9, %eax
je 0x15ea4
jmp 0x15ebd
movl %r12d, %eax
xorl %r12d, %r12d
testb %al, %al
je 0x1608a
cmpl $0x1, %edx
je 0x15f5c
testl %edx, %edx
jne 0x1608a
testq %r8, %r8
leaq 0x2198f(%rip), %r15     # 0x3786f
cmovneq %r8, %r15
movl (%rbx), %eax
movl %eax, -0x28(%rbp)
testb %r12b, %r12b
je 0x15fcd
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1608a
andl $0x0, -0x24(%rbp)
cmpb $0x2a, %r12b
je 0x16060
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x16028
cmpl $0x2b, %eax
jne 0x15fd1
leaq 0x22fca(%rip), %rsi     # 0x38f00
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1608a
cvtsi2ssl -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x16084
testq %r8, %r8
leaq 0x22f9a(%rip), %r15     # 0x38f00
cmovneq %r8, %r15
movss (%rbx), %xmm0
movss %xmm0, -0x28(%rbp)
testb %r12b, %r12b
je 0x15f91
leaq -0x28(%rbp), %rdx
movq %rsi, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1608a
leaq -0x24(%rbp), %rdx
andl $0x0, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
testl %eax, %eax
jle 0x1608a
cmpb $0x2a, %r12b
je 0x16011
movzbl %r12b, %eax
cmpl $0x2f, %eax
je 0x15ff3
cmpl $0x2b, %eax
jne 0x1601d
movss -0x28(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
jmp 0x16022
andl $0x0, -0x24(%rbp)
leaq -0x28(%rbp), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1608a
movl -0x28(%rbp), %eax
jmp 0x16088
movss -0x24(%rbp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x16006
jnp 0x1608a
movss -0x28(%rbp), %xmm0
divss %xmm1, %xmm0
jmp 0x16022
movss -0x28(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
jmp 0x16022
movss -0x24(%rbp), %xmm0
movss %xmm0, (%rbx)
jmp 0x1608a
leaq 0x22ed1(%rip), %rsi     # 0x38f00
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1608a
movss -0x24(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x16051
jnp 0x1608a
cvtsi2ssl -0x28(%rbp), %xmm1
divss %xmm0, %xmm1
cvttss2si %xmm1, %eax
jmp 0x16088
leaq 0x22e99(%rip), %rsi     # 0x38f00
leaq -0x24(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x70c0
cmpl $0x1, %eax
jne 0x1608a
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