// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/open_trace_file.c
// Function: expand_path
static char *expand_path(char *file, char *dirname) {
    size_t len = strlen(dirname);
    size_t lenf = strlen(file);
    char *cp, *path;

    path = malloc(len+lenf+2); // worst expansion DIR/FILE
    if (!path)
	return NULL;

    if (dirname[len-1] == '/')
	len--;

    /* Special case for "./" or absolute filenames */
    if (*file == '/' || (len==1 && *dirname == '.')) {
	sprintf(path, "%s", file);
    } else {
	/* Handle %[0-9]*s expansions, if required */
	char *path_end = path;
	*path = 0;
	while ((cp = strchr(dirname, '%'))) {
	    char *endp;
	    long l = strtol(cp+1, &endp, 10);
	    if (*endp != 's') {
		strncpy(path_end, dirname, (endp+1)-dirname);
		path_end += (endp+1)-dirname;
		dirname = endp+1;
		continue;
	    }
	    
	    strncpy(path_end, dirname, cp-dirname);
	    path_end += cp-dirname;
	    if (l) {
		strncpy(path_end, file, l);
		path_end += MIN(strlen(file), l);
		file     += MIN(strlen(file), l);
	    } else {
		strcpy(path_end, file);
		path_end += strlen(file);
		file     += strlen(file);
	    }
	    len -= (endp+1) - dirname;
	    dirname = endp+1;
	}
	strncpy(path_end, dirname, len);
	path_end += MIN(strlen(dirname), len);
	*path_end = 0;
	if (*file) {
	    *path_end++ = '/';
	    strcpy(path_end, file);
	}
    }

    //fprintf(stderr, "*PATH=\"%s\"\n", path);
    return path;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x62c0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62c0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
addq -0x28(%rbp), %rdi
addq $0x2, %rdi
callq 0x69c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x8fb93
movq $0x0, -0x8(%rbp)
jmp 0x8fe02
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x8fbb4
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x8fbd3
cmpq $0x1, -0x20(%rbp)
jne 0x8fbee
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x8fbee
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x4a42f(%rip), %rsi     # 0xda011
movb $0x0, %al
callq 0x6160
jmp 0x8fdfa
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
movl $0x25, %esi
callq 0x6260
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x8fd86
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
leaq -0x48(%rbp), %rsi
movl $0xa, %edx
callq 0x6a50
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
je 0x8fc83
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq $0x1, %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
callq 0x6370
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8fbfd
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
callq 0x6370
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x8fd2c
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x6370
movq -0x10(%rbp), %rdi
callq 0x62c0
cmpq -0x50(%rbp), %rax
jae 0x8fce4
movq -0x10(%rbp), %rdi
callq 0x62c0
movq %rax, -0x58(%rbp)
jmp 0x8fcec
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62c0
cmpq -0x50(%rbp), %rax
jae 0x8fd16
movq -0x10(%rbp), %rdi
callq 0x62c0
movq %rax, -0x60(%rbp)
jmp 0x8fd1e
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x8fd5b
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6680
movq -0x10(%rbp), %rdi
callq 0x62c0
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62c0
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rcx
addq $0x1, %rcx
movq -0x18(%rbp), %rax
subq %rax, %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8fbfd
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x6370
movq -0x18(%rbp), %rdi
callq 0x62c0
cmpq -0x20(%rbp), %rax
jae 0x8fdb5
movq -0x18(%rbp), %rdi
callq 0x62c0
movq %rax, -0x68(%rbp)
jmp 0x8fdbd
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x8fdf8
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb $0x2f, (%rax)
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6680
jmp 0x8fdfa
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)