// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hfile_libcurl.c
// Function: read_auth_json
static int read_auth_json(auth_token *tok, hFILE *auth_fp) {
    hts_json_token *t = hts_json_alloc_token();
    kstring_t str = {0, 0, NULL};
    char *token = NULL, *type = NULL, *expiry = NULL;
    int ret = 'i';

    if (!t) goto error;

    if ((ret = hts_json_fnext(auth_fp, t, &str)) != '{') goto error;
    while (hts_json_fnext(auth_fp, t, &str) != '}') {
        char *key;
        if (hts_json_token_type(t) != 's') {
            ret = '?';
            goto error;
        }
        key = hts_json_token_str(t);
        if (!key) goto error;
        if (strcmp(key, "access_token") == 0) {
            if ((ret = hts_json_fnext(auth_fp, t, &str)) != 's') goto error;
            token = ks_release(&str);
        } else if (strcmp(key, "token_type") == 0) {
            if ((ret = hts_json_fnext(auth_fp, t, &str)) != 's') goto error;
            type = ks_release(&str);
        } else if (strcmp(key, "expires_in") == 0) {
            if ((ret = hts_json_fnext(auth_fp, t, &str)) != 'n') goto error;
            expiry = ks_release(&str);
        } else if (hts_json_fskip_value(auth_fp, '\0') != 'v') {
            ret = '?';
            goto error;
        }
    }

    if (!token || (type && strcmp(type, "Bearer") != 0)) {
        ret = 'i';
        goto error;
    }

    ret = 'm';
    str.l = 0;
    if (kputs("Authorization: Bearer ", &str) < 0) goto error;
    if (kputs(token, &str) < 0) goto error;
    free(tok->token);
    tok->token = ks_release(&str);
    if (expiry) {
        long exp = strtol(expiry, NULL, 10);
        if (exp < 0) exp = 0;
        tok->expiry = time(NULL) + exp;
    } else {
        tok->expiry = 0;
    }
    ret = 'v';

 error:
    free(token);
    free(type);
    free(expiry);
    free(str.s);
    hts_json_free_token(t);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x4b8d0
movq %rax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4250
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x69, -0x4c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xd1ff4
jmp 0xd224c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4bed0
movsbl %al, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x7b, %eax
je 0xd2015
jmp 0xd224c
jmp 0xd2017
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4bed0
movsbl %al, %eax
cmpl $0x7d, %eax
je 0xd2166
movq -0x18(%rbp), %rdi
callq 0x4b8f0
movsbl %al, %eax
cmpl $0x73, %eax
je 0xd2051
movl $0x3f, -0x4c(%rbp)
jmp 0xd224c
movq -0x18(%rbp), %rdi
callq 0x4b920
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xd206a
jmp 0xd224c
movq -0x58(%rbp), %rdi
leaq 0x25574(%rip), %rsi     # 0xf75e9
callq 0x4690
cmpl $0x0, %eax
jne 0xd20b2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4bed0
movsbl %al, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x73, %eax
je 0xd20a0
jmp 0xd224c
leaq -0x30(%rbp), %rdi
callq 0xd0750
movq %rax, -0x38(%rbp)
jmp 0xd2161
movq -0x58(%rbp), %rdi
leaq 0x25539(%rip), %rsi     # 0xf75f6
callq 0x4690
cmpl $0x0, %eax
jne 0xd20f7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4bed0
movsbl %al, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x73, %eax
je 0xd20e8
jmp 0xd224c
leaq -0x30(%rbp), %rdi
callq 0xd0750
movq %rax, -0x40(%rbp)
jmp 0xd215f
movq -0x58(%rbp), %rdi
leaq 0x254ff(%rip), %rsi     # 0xf7601
callq 0x4690
cmpl $0x0, %eax
jne 0xd213c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x4bed0
movsbl %al, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x6e, %eax
je 0xd212d
jmp 0xd224c
leaq -0x30(%rbp), %rdi
callq 0xd0750
movq %rax, -0x48(%rbp)
jmp 0xd215d
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x4c680
movsbl %al, %eax
cmpl $0x76, %eax
je 0xd215b
movl $0x3f, -0x4c(%rbp)
jmp 0xd224c
jmp 0xd215d
jmp 0xd215f
jmp 0xd2161
jmp 0xd2017
cmpq $0x0, -0x38(%rbp)
je 0xd2189
cmpq $0x0, -0x40(%rbp)
je 0xd2195
movq -0x40(%rbp), %rdi
leaq 0x2548d(%rip), %rsi     # 0xf760c
callq 0x4690
cmpl $0x0, %eax
je 0xd2195
movl $0x69, -0x4c(%rbp)
jmp 0xd224c
movl $0x6d, -0x4c(%rbp)
movq $0x0, -0x30(%rbp)
leaq 0x25468(%rip), %rdi     # 0xf7613
leaq -0x30(%rbp), %rsi
callq 0xd0ed0
cmpl $0x0, %eax
jge 0xd21be
jmp 0xd224c
movq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xd0ed0
cmpl $0x0, %eax
jge 0xd21d2
jmp 0xd224c
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x45a0
leaq -0x30(%rbp), %rdi
callq 0xd0750
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x48(%rbp)
je 0xd2239
movq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x46a0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jge 0xd221f
movq $0x0, -0x60(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x4440
movq %rax, %rcx
addq -0x60(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xd2245
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movl $0x76, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x45a0
movq -0x40(%rbp), %rdi
callq 0x45a0
movq -0x48(%rbp), %rdi
callq 0x45a0
movq -0x20(%rbp), %rdi
callq 0x45a0
movq -0x18(%rbp), %rdi
callq 0x4b900
movl -0x4c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)