// File: /workspace/github_c_makefile_star2_O3/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 0x63d0
leaq 0x10(%rbx), %rdx
leaq 0x18(%rbx), %rcx
leaq 0x20(%rbx), %r8
leaq 0x28(%rbx), %r9
leaq 0x30(%rbx), %rax
movq %rax, (%rsp)
leaq 0x4609(%rip), %rsi      # 0xa9c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %r15d
movl $0x5, %r12d
jmp 0x6402
leaq 0x18(%rbx), %rdx
leaq 0x20(%rbx), %rcx
leaq 0x28(%rbx), %r8
leaq 0x30(%rbx), %r9
leaq 0x45e1(%rip), %rsi      # 0xa9c8
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %r15d
movq $0x0, 0x10(%rbx)
movl $0x4, %r12d
cmpl $0x2, (%rbx)
jne 0x6427
leaq 0x38(%rbx), %rdx
leaq 0x40(%rbx), %rcx
leaq 0x45ba(%rip), %rsi      # 0xa9d0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %r15d
orl $0x2, %r12d
leaq 0x48(%rbx), %rdx
leaq 0x45a2(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %ebp
addl %r15d, %ebp
cmpl $0x2, 0x8(%rbx)
jne 0x6498
movq 0x58(%rbx), %rax
movq (%rax), %rcx
addl %ecx, %r12d
incl %r12d
testq %rcx, %rcx
je 0x64b3
movq %r12, 0x8(%rsp)
leaq 0x456f(%rip), %r15      # 0xa9d4
xorl %r13d, %r13d
xorl %r12d, %r12d
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
addq $0x8, %r13
cmpq (%rax), %r12
jb 0x646b
movq 0x8(%rsp), %r12
jmp 0x64b3
leaq 0x68(%rbx), %rdx
leaq 0x4531(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
addl $0x2, %r12d
cmpl $0x3, 0x8(%rbx)
jne 0x64d3
leaq 0x78(%rbx), %rdx
leaq 0x4510(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
incl %r12d
movsd 0x449d(%rip), %xmm1     # 0xa978
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 0x656f
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 0x96e9
xorl %eax, %eax
cmpl %r12d, %ebp
sete %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop