// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/src/dio.c
// Function: updateConfig
static void updateConfig(const char *configContents, const char *dstPath) {
    file_t file;
    file_init(&file, 500000);
    const char *start = configContents;
    const testResult_t *testResult = testResults.head;
    while (testResult) {
        const char *end = testResult->gasUsedBegin;
        file_ensure(&file, file.num_chars + (end - start));
        memcpy(file.chars + file.num_chars, start, end - start);
        file.num_chars += (end - start);
        start = testResult->gasUsedEnd;
        if (start == end) {
            // need to add gasUsed key
            const char gasUsedHeader[] = ",\n                \"gasUsed\": \"0x";
            file_ensure(&file, file.num_chars + (end - start));
            memcpy(file.chars + file.num_chars, gasUsedHeader, sizeof(gasUsedHeader) - 1);
            file.num_chars += sizeof(gasUsedHeader) - 1;
        }
        file_ensure(&file, file.num_chars + 18);
        file.num_chars += snprintf(file.chars + file.num_chars, file.buffer_size - file.num_chars, "%" PRIx64, testResult->gasUsed);
        if (start == end) {
            file.chars[file.num_chars] = '"';
            file.num_chars += 1;
        }
        testResult = testResult->next;
    }

    size_t remaining = strlen(start);
    memcpy(file.chars + file.num_chars, start, remaining);
    file.num_chars += remaining;

    int fd = open(dstPath, O_WRONLY);
    if (fd == -1) {
        perror(dstPath);
        exit(1);
    }
    ssize_t written = write(fd, file.chars, file.num_chars);
    if (written == -1) {
        perror(dstPath);
        exit(1);
    }
    close(fd);
    file_destroy(&file);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
callq 0x7cd0
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0x22f48(%rip), %rax     # 0x28a28
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x5c35
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
addq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d20
movq -0x20(%rbp), %rdi
addq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x30(%rbp), %rax
subq %rax, %rdx
callq 0x3200
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x5bc2
leaq -0x70(%rbp), %rdi
leaq 0x14a2a(%rip), %rsi     # 0x1a590
movl $0x21, %edx
callq 0x3200
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
addq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d20
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq %rdx, (%rax,%rcx)
movq -0x68(%rbp), %rdx
movq %rdx, 0x8(%rax,%rcx)
movq -0x60(%rbp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movq -0x58(%rbp), %rdx
movq %rdx, 0x18(%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
addq $0x12, %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d20
movq -0x20(%rbp), %rdi
addq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
subq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x14994(%rip), %rdx     # 0x1a586
movb $0x0, %al
callq 0x3110
cltq
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x5c25
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movb $0x22, (%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x5ae4
movq -0x30(%rbp), %rdi
callq 0x30c0
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
addq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x3200
movq -0x78(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movb $0x0, %al
callq 0x3250
movl %eax, -0x7c(%rbp)
cmpl $-0x1, -0x7c(%rbp)
jne 0x5c8f
movq -0x10(%rbp), %rdi
callq 0x3260
movl $0x1, %edi
callq 0x3280
movl -0x7c(%rbp), %edi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x30b0
movq %rax, -0x88(%rbp)
cmpq $-0x1, -0x88(%rbp)
jne 0x5cc3
movq -0x10(%rbp), %rdi
callq 0x3260
movl $0x1, %edi
callq 0x3280
movl -0x7c(%rbp), %edi
callq 0x3160
leaq -0x28(%rbp), %rdi
callq 0x7da0
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)