// File: /workspace/github_c_makefile_star2_O1/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 0x6348
leaq 0x10(%rbx), %rdx
leaq 0x18(%rbx), %rcx
leaq 0x20(%rbx), %r8
leaq 0x28(%rbx), %r9
leaq 0x30(%rbx), %rax
movq %rax, (%rsp)
leaq 0x4691(%rip), %rsi      # 0xa9c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %r15d
movl $0x5, %r12d
jmp 0x637a
leaq 0x18(%rbx), %rdx
leaq 0x20(%rbx), %rcx
leaq 0x28(%rbx), %r8
leaq 0x30(%rbx), %r9
leaq 0x4669(%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 0x639f
leaq 0x38(%rbx), %rdx
leaq 0x40(%rbx), %rcx
leaq 0x4642(%rip), %rsi      # 0xa9d0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %r15d
orl $0x2, %r12d
leaq 0x48(%rbx), %rdx
leaq 0x462a(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
movl %eax, %ebp
addl %r15d, %ebp
cmpl $0x2, 0x8(%rbx)
jne 0x6410
movq 0x58(%rbx), %rax
movq (%rax), %rcx
addl %ecx, %r12d
incl %r12d
testq %rcx, %rcx
je 0x642b
movq %r12, 0x8(%rsp)
leaq 0x45f7(%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 0x63e3
movq 0x8(%rsp), %r12
jmp 0x642b
leaq 0x68(%rbx), %rdx
leaq 0x45b9(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
addl $0x2, %r12d
cmpl $0x3, 0x8(%rbx)
jne 0x644b
leaq 0x78(%rbx), %rdx
leaq 0x4598(%rip), %rsi      # 0xa9d4
movq %r14, %rdi
xorl %eax, %eax
callq 0x2080
addl %eax, %ebp
incl %r12d
movsd 0x4525(%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 0x64e7
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 0x95c5
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