// File: /workspace/github_c_makefile_star2_O1/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/Parse_Text.c
// Function: Parse_Text
void Parse_Text(FILE *fp, const char *querystring, const char type,
              void* result){
    int32_t res = 0, found = 0;

    /* Start from the beginning */
    rewind(fp);

    /* Look for the string until found */
    while (!found) {
        char line[LINESIZE];
        char delimiters[] = " =\n\r";
        char *name, *value;

        /* Read in one line */
        if (fgets(line, LINESIZE, fp) == NULL)
            break;

        name = strtok(line, delimiters);
        if ((name != NULL) && (strcmp(name, querystring) == 0)) {
            found = 1;
            value = strtok(NULL, delimiters);

            switch (type) {
            case 'i':
                res = sscanf(value, "%d", (int *)result);
                break;
            case 'I':
                res = sscanf(value, "%d", (int32_t *)result);
                break;
            case 'f':
                res = sscanf(value, "%f", (float *)result);
                break;
            case 'd':
                res = sscanf(value, "%lf", (double *)result);
                break;
            case 's':
                res = 1;
                strcpy((char *)result, value);
                break;
            default:
                fprintf(stderr, "parsetext: unknown type %c\n", type);
                exit(1);
            }
        }

    }

    if (found == 0){
        fprintf(stderr,"\n !!! CANNOT FIND %s IN INPUT FILE\n", querystring);
        fprintf(stderr,"Using default value for calculation.\n");
    }
    if (res == -1){
        fprintf(stderr, "parsetext: unknown type %c\n", type);
        exit(1);
    }

    return ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rcx, 0x8(%rsp)
movl %edx, %ebx
movq %rsi, 0x18(%rsp)
movq %rdi, %r12
callq 0x1090
leaq 0x20(%rsp), %r13
movl %ebx, 0x14(%rsp)
movsbl %bl, %r14d
xorl %ebp, %ebp
xorl %r15d, %r15d
testl %ebp, %ebp
jne 0x585e
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdx
callq 0x10e0
movq %rax, %rbx
testq %rax, %rax
je 0x5839
movq %r13, %rdi
leaq 0x21a1(%rip), %rsi      # 0x794a
callq 0x1170
testq %rax, %rax
je 0x5839
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x10f0
testl %eax, %eax
jne 0x5839
xorl %edi, %edi
leaq 0x2179(%rip), %rsi      # 0x794a
callq 0x1170
cmpl $0x65, %r14d
jle 0x57f3
cmpl $0x66, %r14d
je 0x581b
cmpl $0x73, %r14d
je 0x5844
cmpl $0x69, %r14d
je 0x580f
jmp 0x5890
cmpl $0x49, %r14d
je 0x580f
cmpl $0x64, %r14d
jne 0x5890
movq %rax, %rdi
leaq 0x2142(%rip), %rsi      # 0x794f
jmp 0x5825
movq %rax, %rdi
leaq 0xb5c(%rip), %rsi       # 0x6375
jmp 0x5825
movq %rax, %rdi
leaq 0x1601(%rip), %rsi      # 0x6e26
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x1130
movl %eax, %r15d
movl $0x1, %ebp
testq %rbx, %rbx
jne 0x577b
jmp 0x585e
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x1030
movl $0x1, %ebp
movl $0x1, %r15d
jmp 0x5839
testl %ebp, %ebp
je 0x587a
cmpl $-0x1, %r15d
je 0x5886
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
callq 0x1d46
jmp 0x5862
movzbl 0x14(%rsp), %edi
callq 0x1d79
movzbl 0x14(%rsp), %edi
callq 0x1d21