// File: /workspace/github_c_makefile_star2_O2/esheldon[P]xshear/src/source.c
// Function: source_read
int source_read(FILE* stream, Source* src) {
    size_t i=0;
    double ra_rad,dec_rad;
    int nread=0;
    int nexpect=0;

    if(src->sourceid_style==SOURCEID_STYLE_INDEX) {
    	nread += fscanf(stream, "%ld %lf %lf %lf %lf", 
                    &src->index,
                    &src->ra, &src->dec,
                    &src->g1, &src->g2);
    	nexpect += 5;
    } else {
    	nread += fscanf(stream, "%lf %lf %lf %lf",
                    &src->ra, &src->dec,
                    &src->g1, &src->g2);
    	src->index=0;
    	nexpect += 4;    
    }

    if (src->shear_style==SHEAR_STYLE_LENSFIT) {
        nread += fscanf(stream, "%lf %lf", &src->g1sens, &src->g2sens);
        nexpect += 2;
    }

    nread += fscanf(stream, "%lf", &src->weight);

    nexpect += 1;

    if (src->scstyle == SIGMACRIT_STYLE_INTERP) {
        nexpect += src->scinv->size;
        for (i=0; i<src->scinv->size; i++) {
            nread += fscanf(stream,"%lf", &src->scinv->data[i]);
        }
    } else {
        nread += fscanf(stream,"%lf", &src->z);
        nexpect += 1;
    }

    if (src->scstyle == SIGMACRIT_STYLE_SAMPLE) {
        nread += fscanf(stream,"%lf", &src->zs);
        nexpect += 1;
    }

    ra_rad = src->ra*D2R;
    dec_rad = src->dec*D2R;
    src->sinra = sin(ra_rad);
    src->cosra = cos(ra_rad);
    src->sindec = sin(dec_rad);
    src->cosdec = cos(dec_rad);

    // add sin(lam),cos(lam),sin(eta),cos(eta)
    if (src->mask_style == MASK_STYLE_SDSS) {
        eq2sdss_sincos(src->ra,src->dec,
                &src->sinlam, &src->coslam,
                &src->sineta, &src->coseta);
    }

    return (nread == nexpect);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x2, 0xc(%rsi)
jne 0x4e73
leaq 0x10(%rbx), %rdx
leaq 0x18(%rbx), %rcx
leaq 0x20(%rbx), %r8
leaq 0x28(%rbx), %r9
leaq 0x30(%rbx), %rax
movq %rax, (%rsp)
leaq 0x4b62(%rip), %rsi      # 0x99c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %r15d
pushq $0x5
jmp 0x4e9e
leaq 0x18(%rbx), %rdx
leaq 0x20(%rbx), %rcx
leaq 0x28(%rbx), %r8
leaq 0x30(%rbx), %r9
leaq 0x4b3e(%rip), %rsi      # 0x99c8
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %r15d
andq $0x0, 0x10(%rbx)
pushq $0x4
popq %r12
cmpl $0x2, (%rbx)
jne 0x4ec5
leaq 0x38(%rbx), %rdx
leaq 0x40(%rbx), %rcx
leaq 0x4b1c(%rip), %rsi      # 0x99d0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %r15d
orl $0x2, %r12d
leaq 0x48(%rbx), %rdx
leaq 0x4b04(%rip), %rsi      # 0x99d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %ebp
addl %r15d, %ebp
cmpl $0x2, 0x8(%rbx)
jne 0x4f40
movq %r12, 0x8(%rsp)
movq 0x58(%rbx), %rax
movq (%rax), %rcx
leaq 0x4adc(%rip), %r15      # 0x99d4
xorl %r13d, %r13d
movq %rcx, 0x10(%rsp)
xorl %r12d, %r12d
cmpq %rcx, %r12
jae 0x4f2e
movq 0x10(%rax), %rdx
addq %r13, %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
incq %r12
movq 0x58(%rbx), %rax
movq (%rax), %rcx
addq $0x8, %r13
jmp 0x4f03
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %rax
addl %eax, %r12d
incl %r12d
jmp 0x4f5b
leaq 0x68(%rbx), %rdx
leaq 0x4a89(%rip), %rsi      # 0x99d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
addl $0x2, %r12d
cmpl $0x3, 0x8(%rbx)
jne 0x4f7b
leaq 0x78(%rbx), %rdx
leaq 0x4a68(%rip), %rsi      # 0x99d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
incl %r12d
movsd 0x49f5(%rip), %xmm1     # 0x9978
movsd 0x18(%rbx), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
mulsd 0x20(%rbx), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0x2260
movsd %xmm0, 0x88(%rbx)
movsd 0x10(%rsp), %xmm0
callq 0x2150
movsd %xmm0, 0x90(%rbx)
movsd 0x8(%rsp), %xmm0
callq 0x2260
movsd %xmm0, 0x98(%rbx)
movsd 0x8(%rsp), %xmm0
callq 0x2150
movsd %xmm0, 0xa0(%rbx)
cmpl $0x2, 0x4(%rbx)
jne 0x5017
movsd 0x18(%rbx), %xmm0
movsd 0x20(%rbx), %xmm1
leaq 0xa8(%rbx), %rdi
leaq 0xb0(%rbx), %rsi
leaq 0xb8(%rbx), %rdx
addq $0xc0, %rbx
movq %rbx, %rcx
callq 0x8bca
xorl %eax, %eax
cmpl %r12d, %ebp
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq