// File: /workspace/github_c_makefile_star2_O2/sonicse[P]dbf2mysql/dbf2mysql.c
// Function: do_substitute
void do_substitute(char *subarg, dbhead *dbh) {
    /* NOTE: subarg is modified in this function */
    int i, bad;
    char *p, *oldname, *newname;
    if (subarg == NULL) return;

    if (verbose > 1) {
        printf("Substituting new field names\n");
    }
    /* use strstr instead of strtok because of possible empty tokens */
    oldname = subarg;
    while (oldname && strlen(oldname) && (p = strstr(oldname, "="))) {
        *p = '\0'; /* mark end of oldname */
        newname = ++p; /* point past \0 of oldname */
        if (strlen(newname)) { /* if not an empty string */
            p = strstr(newname, ",");
            if (p) {
                *p = '\0'; /* mark end of newname */
                p++; /* point past where the comma was */
            }
        }
        if (strlen(newname) >= DBF_NAMELEN) {
            printf("Truncating new field name %s to %d chars\n",
                    newname, DBF_NAMELEN - 1);
            newname[DBF_NAMELEN - 1] = '\0';
        }
        bad = 1;
        for (i = 0; i < dbh->db_nfields; i++) {
            if (strcmp(dbh->db_fields[i].db_name, oldname) == 0) {
                bad = 0;
                strcpy(dbh->db_fields[i].db_name, newname);
                if (verbose > 1) {
                    printf("Substitute old:%s new:%s\n",
                            oldname, newname);
                }
                break;
            }
        }
        if (bad) {
            printf("Warning: old field name %s not found\n",
                    oldname);
        }
        oldname = p;
    }
}

// Assembly:
testq %rdi, %rdi
je 0x2831
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r15
cmpl $0x2, 0x6b11(%rip)      # 0x9210
jl 0x270d
leaq 0x41b9(%rip), %rdi      # 0x68c1
callq 0x22f0
testq %r15, %r15
je 0x2823
movq %r15, %r14
cmpb $0x0, (%r15)
je 0x2823
movq %r14, %rdi
pushq $0x3d
popq %rsi
callq 0x20b0
testq %rax, %rax
je 0x2823
movq %rax, %r15
movb $0x0, (%rax)
movq %rax, %r12
incq %r12
cmpb $0x0, 0x1(%rax)
movq %r12, %rax
je 0x2766
movq %r12, %rdi
pushq $0x2c
popq %rsi
callq 0x20b0
testq %rax, %rax
je 0x2764
movb $0x0, (%rax)
incq %rax
jmp 0x2766
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x20d0
cmpq $0xb, %rax
jb 0x2792
leaq 0x39e4(%rip), %rdi      # 0x6164
movq %r12, %rsi
pushq $0xa
popq %rdx
xorl %eax, %eax
callq 0x2050
movb $0x0, 0xb(%r15)
movq %r12, 0x10(%rsp)
movzbl 0x32(%rbx), %eax
imulq $0xf, %rax, %rbp
xorl %r12d, %r12d
pushq $0xf
popq %r13
addq $-0xf, %r13
movq %rbp, %rax
addq %r13, %rax
je 0x2808
movq 0x40(%rbx), %r15
leaq (%r15,%r12), %rdi
addq $0xf, %r12
movq %r14, %rsi
callq 0x22b0
testl %eax, %eax
jne 0x27a6
subq %r13, %r15
movq %r15, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0x21b0
cmpl $0x2, 0x6a2c(%rip)      # 0x9210
movq 0x8(%rsp), %r15
jl 0x270d
leaq 0x3998(%rip), %rdi      # 0x618e
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2050
jmp 0x270d
leaq 0x3999(%rip), %rdi      # 0x61a8
movq %r14, %rsi
xorl %eax, %eax
callq 0x2050
movq 0x8(%rsp), %r15
jmp 0x270d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq