// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/src/dio.c
// Function: derivePath
static void derivePath() {
    if (derivedPath != NULL) {
        return;
    }
    if (selfPath[0] == '/') {
        // absolute path
        derivedPath = selfPath;
        return;
    }
    const char *pathWalk = selfPath;
    char *relativePath = malloc(MAXPATHLEN + 1);
    while (*pathWalk) {
        if (*pathWalk == '/') {
            // relative path
            if (getcwd(relativePath, MAXPATHLEN + 1) == NULL) {
                perror("getcwd");
                exit(1);
            }
            size_t offset = strlen(relativePath);
            relativePath[offset++] = '/';
            relativePath[offset] = '\0';
            strcpy(relativePath + offset, selfPath);
            derivedPath = relativePath;
            return;
        }
        pathWalk++;
    }
    // look through $PATH
    char *path = getenv("PATH");
    struct stat statResult;
    while (*path) {
        char *next = strchr(path,':');
        if (next == NULL) {
            break;
        }
        char *end = stpncpy(relativePath, path, next - path);
        *end++ = '/';
        strcpy(end, selfPath);
        if (stat(relativePath, &statResult) == -1) {
            //perror(relativePath);
            path = next + 1;
        } else {
            derivedPath = relativePath;
            return;
        }
    }
    fputs("evm: could not find evm\n", stderr);
    _exit(-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
cmpq $0x0, 0x211a5(%rip)     # 0x28a48
je 0x78aa
jmp 0x7a73
movq 0x2116f(%rip), %rax     # 0x28a20
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x78cc
movq 0x21160(%rip), %rax     # 0x28a20
movq %rax, 0x21181(%rip)     # 0x28a48
jmp 0x7a73
movq 0x2114d(%rip), %rax     # 0x28a20
movq %rax, -0x8(%rbp)
movl $0x1001, %edi           # imm = 0x1001
callq 0x3210
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpb $0x0, (%rax)
je 0x798d
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x797c
movq -0x10(%rbp), %rdi
movl $0x1001, %esi           # imm = 0x1001
callq 0x3150
cmpq $0x0, %rax
jne 0x7928
leaq 0x12a68(%rip), %rdi     # 0x1a381
callq 0x3260
movl $0x1, %edi
callq 0x3280
movq -0x10(%rbp), %rdi
callq 0x30c0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x18(%rbp)
movb $0x2f, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq 0x210b9(%rip), %rsi     # 0x28a20
callq 0x3090
movq -0x10(%rbp), %rax
movq %rax, 0x210d1(%rip)     # 0x28a48
jmp 0x7a73
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x78e5
leaq 0x129f4(%rip), %rdi     # 0x1a388
callq 0x3030
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x7a53
movq -0x20(%rbp), %rdi
movl $0x3a, %esi
callq 0x30f0
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
jne 0x79ce
jmp 0x7a53
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
callq 0x3220
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0xc0(%rbp)
movb $0x2f, (%rax)
movq -0xc0(%rbp), %rdi
movq 0x2100a(%rip), %rsi     # 0x28a20
callq 0x3090
movq -0x10(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x31f0
cmpl $-0x1, %eax
jne 0x7a41
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x7a4e
movq -0x10(%rbp), %rax
movq %rax, 0x20ffc(%rip)     # 0x28a48
jmp 0x7a73
jmp 0x799d
movq 0x1859e(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12929(%rip), %rdi     # 0x1a38d
callq 0x3130
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3080
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)