// File: karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_populate_ref
static int cram_populate_ref(cram_fd *fd, int id, ref_entry *r) {
    char *ref_path = getenv("REF_PATH");
    SAM_hdr_type *ty;
    SAM_hdr_tag *tag;
    char path[PATH_MAX], path_tmp[PATH_MAX];
    char cache[PATH_MAX], cache_root[PATH_MAX];
    char *local_cache = getenv("REF_CACHE");
    mFILE *mf;
    int local_path = 0;

    if (fd->verbose)
	fprintf(stderr, "cram_populate_ref on fd %p, id %d\n", fd, id);

    cache_root[0] = '\0';

    if (!ref_path || *ref_path == '\0') {
	/*
	 * If we have no ref path, we use the EBI server.
	 * However to avoid spamming it we require a local ref cache too.
	 */
	ref_path = "http://www.ebi.ac.uk:80/ena/cram/md5/%s";
	if (!local_cache || *local_cache == '\0') {
	    const char *extra;
	    const char *base = get_cache_basedir(&extra);
	    snprintf(cache_root, PATH_MAX, "%s%s/hts-ref", base, extra);
	    snprintf(cache,PATH_MAX, "%s%s/hts-ref/%%2s/%%2s/%%s", base, extra);
	    local_cache = cache;
	    if (fd->verbose)
		fprintf(stderr, "Populating local cache: %s\n", local_cache);
	}
    }

    if (!r->name)
	return -1;

    if (!(ty = sam_hdr_find(fd->header, "SQ", "SN", r->name)))
	return -1;

    if (!(tag = sam_hdr_find_key(fd->header, ty, "M5", NULL)))
	goto no_M5;

    if (fd->verbose)
	fprintf(stderr, "Querying ref %s\n", tag->str+3);

    /* Use cache if available */
    if (local_cache && *local_cache) {
	expand_cache_path(path, local_cache, tag->str+3);
	local_path = 1;
    }

#ifndef HAVE_MMAP
    char *path2;
    /* Search local files in REF_PATH; we can open them and return as above */
    if (!local_path && (path2 = find_path(tag->str+3, ref_path))) {
	strncpy(path, path2, PATH_MAX);
	free(path2);
	if (is_file(path)) // incase it's too long
	    local_path = 1;
    }
#endif

    /* Found via REF_CACHE or local REF_PATH file */
    if (local_path) {
	struct stat sb;
	BGZF *fp;

	if (0 == stat(path, &sb) && (fp = bgzf_open(path, "r"))) {
	    r->length = sb.st_size;
	    r->offset = r->line_length = r->bases_per_line = 0;

	    r->fn = string_dup(fd->refs->pool, path);

	    if (fd->refs->fp)
		if (bgzf_close(fd->refs->fp) != 0)
		    return -1;
	    fd->refs->fp = fp;
	    fd->refs->fn = r->fn;
	    r->is_md5 = 1;

	    // Fall back to cram_get_ref() where it'll do the actual
	    // reading of the file.
	    return 0;
	}
    }


    /* Otherwise search full REF_PATH; slower as loads entire file */
    if ((mf = open_path_mfile(tag->str+3, ref_path, NULL))) {
	size_t sz;
	r->seq = mfsteal(mf, &sz);
	if (r->seq) {
	    r->mf = NULL;
	} else {
	    // keep mf around as we couldn't detach
	    r->seq = mf->data;
	    r->mf = mf;
	}
	r->length = sz;
	r->is_md5 = 1;
    } else {
	refs_t *refs;
	char *fn;

    no_M5:
	/* Failed to find in search path or M5 cache, see if @SQ UR: tag? */
	if (!(tag = sam_hdr_find_key(fd->header, ty, "UR", NULL)))
	    return -1;

	fn = (strncmp(tag->str+3, "file:", 5) == 0)
	    ? tag->str+8
	    : tag->str+3;

	if (fd->refs->fp) {
	    if (bgzf_close(fd->refs->fp) != 0)
		return -1;
	    fd->refs->fp = NULL;
	}
	if (!(refs = refs_load_fai(fd->refs, fn, 0)))
	    return -1;
	sanitise_SQ_lines(fd);

	fd->refs = refs;
	if (fd->refs->fp) {
	    if (bgzf_close(fd->refs->fp) != 0)
		return -1;
	    fd->refs->fp = NULL;
	}

	if (!fd->refs->fn)
	    return -1;

	if (-1 == refs2id(fd->refs, fd->header))
	    return -1;
	if (!fd->refs->ref_id || !fd->refs->ref_id[id])
	    return -1;

	// Local copy already, so fall back to cram_get_ref().
	return 0;
    }

    /* Populate the local disk cache if required */
    if (local_cache && *local_cache) {
	int pid = (int) getpid();
	unsigned thrid = get_int_threadid();
	hFILE *fp;

	if (*cache_root && !is_directory(cache_root) && hts_verbose >= 1)
	    fprintf(stderr,
"Creating reference cache directory %s\n"
"This may become large; see the samtools(1) manual page REF_CACHE discussion\n",
		    cache_root);

	expand_cache_path(path, local_cache, tag->str+3);
	if (fd->verbose)
	    fprintf(stderr, "Writing cache file '%s'\n", path);
	mkdir_prefix(path, 01777);

	do {
	    // Attempt to further uniquify the temporary filename
	    unsigned t = ((unsigned) time(NULL)) ^ ((unsigned) clock());
	    thrid++; // Ensure filename changes even if time/clock haven't

	    sprintf(path_tmp, "%s.tmp_%d_%u_%u", path, pid, thrid, t);
	    fp = hopen(path_tmp, "wx");
	} while (fp == NULL && errno == EEXIST);
	if (!fp) {
	    perror(path_tmp);

	    // Not fatal - we have the data already so keep going.
	    return 0;
	}

	// Check md5sum
	hts_md5_context *md5;
	char unsigned md5_buf1[16];
	char md5_buf2[33];

	if (!(md5 = hts_md5_init())) {
	    hclose_abruptly(fp);
	    unlink(path_tmp);
	    return -1;
	}
	hts_md5_update(md5, r->seq, r->length);
	hts_md5_final(md5_buf1, md5);
	hts_md5_destroy(md5);
	hts_md5_hex(md5_buf2, md5_buf1);

	if (strncmp(tag->str+3, md5_buf2, 32) != 0) {
	    fprintf(stderr, "[E::%s] mismatching md5sum for downloaded reference.\n", __func__);
	    hclose_abruptly(fp);
	    unlink(path_tmp);
	    return -1;
	}

	if (hwrite(fp, r->seq, r->length) != r->length) {
	    perror(path);
	}
	if (hclose(fp) < 0) {
	    unlink(path_tmp);
	} else {
	    if (0 == chmod(path_tmp, 0444))
		rename(path_tmp, path);
	    else
		unlink(path_tmp);
	}
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4190, %rsp           # imm = 0x4190
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x33443(%rip), %rdi     # 0x7d250
callq 0x46e0
movq %rax, -0x28(%rbp)
leaq 0x3343c(%rip), %rdi     # 0x7d259
callq 0x46e0
movq %rax, -0x4048(%rbp)
movl $0x0, -0x4054(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
je 0x49e5f
movq 0x40189(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
leaq 0x3340b(%rip), %rsi     # 0x7d263
movb $0x0, %al
callq 0x4830
movb $0x0, -0x4040(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x49e7d
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x49f46
leaq 0x33402(%rip), %rax     # 0x7d286
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x4048(%rbp)
je 0x49ea5
movq -0x4048(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x49f44
leaq -0x4060(%rbp), %rdi
callq 0x543f0
movq %rax, -0x4068(%rbp)
leaq -0x4040(%rbp), %rdi
movq -0x4068(%rbp), %rcx
movq -0x4060(%rbp), %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x333d5(%rip), %rdx     # 0x7d2ae
movb $0x0, %al
callq 0x4950
leaq -0x3040(%rbp), %rdi
movq -0x4068(%rbp), %rcx
movq -0x4060(%rbp), %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x333ba(%rip), %rdx     # 0x7d2bb
movb $0x0, %al
callq 0x4950
leaq -0x3040(%rbp), %rax
movq %rax, -0x4048(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
je 0x49f42
movq 0x400a6(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
movq -0x4048(%rbp), %rdx
leaq 0x3339b(%rip), %rsi     # 0x7d2d6
movb $0x0, %al
callq 0x4830
jmp 0x49f44
jmp 0x49f46
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x49f5c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rcx
leaq 0x314e8(%rip), %rsi     # 0x7b45a
leaq 0x33113(%rip), %rdx     # 0x7d08c
callq 0x5d1a0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x49f94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
leaq 0x330e8(%rip), %rdx     # 0x7d08f
xorl %eax, %eax
movl %eax, %ecx
callq 0x5d910
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x49fbf
jmp 0x4a254
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
je 0x49ff0
movq 0x3fffd(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
addq $0x3, %rdx
leaq 0x33309(%rip), %rsi     # 0x7d2f2
movb $0x0, %al
callq 0x4830
cmpq $0x0, -0x4048(%rbp)
je 0x4a032
movq -0x4048(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x4a032
leaq -0x1040(%rbp), %rdi
movq -0x4048(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
addq $0x3, %rdx
callq 0x48c80
movl $0x1, -0x4054(%rbp)
cmpl $0x0, -0x4054(%rbp)
jne 0x4a09e
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
movq -0x28(%rbp), %rsi
callq 0x57be0
movq %rax, -0x4070(%rbp)
cmpq $0x0, %rax
je 0x4a09e
leaq -0x1040(%rbp), %rdi
movq -0x4070(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x42c0
movq -0x4070(%rbp), %rdi
callq 0x46a0
leaq -0x1040(%rbp), %rdi
callq 0x55d70
cmpl $0x0, %eax
je 0x4a09c
movl $0x1, -0x4054(%rbp)
jmp 0x4a09e
cmpl $0x0, -0x4054(%rbp)
je 0x4a1b4
leaq -0x1040(%rbp), %rdi
leaq -0x4100(%rbp), %rsi
callq 0x44f0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4a1b2
leaq -0x1040(%rbp), %rdi
leaq 0x31917(%rip), %rsi     # 0x7b9ef
callq 0x62d50
movq %rax, -0x4108(%rbp)
cmpq $0x0, %rax
je 0x4a1b2
movq -0x40d0(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rdi
leaq -0x1040(%rbp), %rsi
callq 0x60170
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x4a174
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x65880
cmpl $0x0, %eax
je 0x4a172
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
jmp 0x4a174
movq -0x4108(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x40(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4a757
jmp 0x4a1b4
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x57970
movq %rax, -0x4050(%rbp)
cmpq $0x0, %rax
je 0x4a252
movq -0x4050(%rbp), %rdi
leaq -0x4110(%rbp), %rsi
callq 0x568e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x4a211
movq -0x20(%rbp), %rax
movq $0x0, 0x38(%rax)
jmp 0x4a233
movq -0x4050(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x4050(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x4110(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movl $0x1, 0x40(%rax)
jmp 0x4a42c
jmp 0x4a254
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
leaq 0x32e2b(%rip), %rdx     # 0x7d092
xorl %eax, %eax
movl %eax, %ecx
callq 0x5d910
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x4a286
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
leaq 0x3306a(%rip), %rsi     # 0x7d303
movl $0x5, %edx
callq 0x4290
cmpl $0x0, %eax
jne 0x4a2bd
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x8, %rax
movq %rax, -0x4188(%rbp)
jmp 0x4a2d0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x3, %rax
movq %rax, -0x4188(%rbp)
movq -0x4188(%rbp), %rax
movq %rax, -0x4120(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x4a31f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x65880
cmpl $0x0, %eax
je 0x4a30f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x4120(%rbp), %rsi
xorl %edx, %edx
callq 0x4a910
movq %rax, -0x4118(%rbp)
cmpq $0x0, %rax
jne 0x4a34e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rdi
callq 0x4b070
movq -0x4118(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x4a3a7
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x65880
cmpl $0x0, %eax
je 0x4a397
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x4a3c2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x48700
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x4a3ee
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x4a414
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x4a420
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movl $0x0, -0x4(%rbp)
jmp 0x4a757
cmpq $0x0, -0x4048(%rbp)
je 0x4a750
movq -0x4048(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x4a750
callq 0x4870
movl %eax, -0x4124(%rbp)
callq 0x544f0
movl %eax, -0x4128(%rbp)
movsbl -0x4040(%rbp), %eax
cmpl $0x0, %eax
je 0x4a4ab
leaq -0x4040(%rbp), %rdi
callq 0x55d10
cmpl $0x0, %eax
jne 0x4a4ab
leaq 0x40159(%rip), %rax     # 0x8a5e0
cmpl $0x1, (%rax)
jl 0x4a4ab
movq 0x3fb3d(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
leaq -0x4040(%rbp), %rdx
leaq 0x32e65(%rip), %rsi     # 0x7d309
movb $0x0, %al
callq 0x4830
leaq -0x1040(%rbp), %rdi
movq -0x4048(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
addq $0x3, %rdx
callq 0x48c80
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1fc(%rax)
je 0x4a4f6
movq 0x3faf2(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
leaq -0x1040(%rbp), %rdx
leaq 0x32e8d(%rip), %rsi     # 0x7d37c
movb $0x0, %al
callq 0x4830
leaq -0x1040(%rbp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
callq 0x48ed0
xorl %eax, %eax
movl %eax, %edi
callq 0x4520
movl %eax, -0x418c(%rbp)
callq 0x4380
movq %rax, %rcx
movl -0x418c(%rbp), %eax
xorl %ecx, %eax
movl %eax, -0x4134(%rbp)
movl -0x4128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4128(%rbp)
leaq -0x2040(%rbp), %rdi
leaq -0x1040(%rbp), %rdx
movl -0x4124(%rbp), %ecx
movl -0x4128(%rbp), %r8d
movl -0x4134(%rbp), %r9d
leaq 0x32e31(%rip), %rsi     # 0x7d395
movb $0x0, %al
callq 0x4100
leaq -0x2040(%rbp), %rdi
leaq 0x32e2c(%rip), %rsi     # 0x7d3a5
callq 0x6b3f0
movq %rax, -0x4130(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x4130(%rbp)
movb %al, -0x418d(%rbp)
jne 0x4a5a8
callq 0x4070
cmpl $0x11, (%rax)
sete %al
movb %al, -0x418d(%rbp)
movb -0x418d(%rbp), %al
testb $0x1, %al
jne 0x4a507
cmpq $0x0, -0x4130(%rbp)
jne 0x4a5d8
leaq -0x2040(%rbp), %rdi
callq 0x4480
movl $0x0, -0x4(%rbp)
jmp 0x4a757
callq 0x6dc50
movq %rax, -0x4140(%rbp)
cmpq $0x0, %rax
jne 0x4a60e
movq -0x4130(%rbp), %rdi
callq 0x6ae00
leaq -0x2040(%rbp), %rdi
callq 0x4280
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x4140(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x6c860
leaq -0x4150(%rbp), %rdi
movq -0x4140(%rbp), %rsi
callq 0x6d9c0
movq -0x4140(%rbp), %rdi
callq 0x6dca0
leaq -0x4180(%rbp), %rdi
leaq -0x4150(%rbp), %rsi
callq 0x6dcd0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
leaq -0x4180(%rbp), %rsi
movl $0x20, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x4a6c1
movq 0x3f94b(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
leaq 0x32d19(%rip), %rsi     # 0x7d3a8
leaq 0x32d48(%rip), %rdx     # 0x7d3de
movb $0x0, %al
callq 0x4830
movq -0x4130(%rbp), %rdi
callq 0x6ae00
leaq -0x2040(%rbp), %rdi
callq 0x4280
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4a757
movq -0x4130(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x43620
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
je 0x4a6f3
leaq -0x1040(%rbp), %rdi
callq 0x4480
movq -0x4130(%rbp), %rdi
callq 0x6ad60
cmpl $0x0, %eax
jge 0x4a712
leaq -0x2040(%rbp), %rdi
callq 0x4280
jmp 0x4a74e
leaq -0x2040(%rbp), %rdi
movl $0x124, %esi            # imm = 0x124
callq 0x4500
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4a740
leaq -0x2040(%rbp), %rdi
leaq -0x1040(%rbp), %rsi
callq 0x4330
jmp 0x4a74c
leaq -0x2040(%rbp), %rdi
callq 0x4280
jmp 0x4a74e
jmp 0x4a750
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x4190, %rsp           # imm = 0x4190
popq %rbp
retq
nopw %cs:(%rax,%rax)