// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::init_raw(bamboo::raw_t*, int)
extern int init_raw(raw_t *raw, int format)
{
    const double lam_glo[NFREQ]={CLIGHT/FREQ1_GLO,CLIGHT/FREQ2_GLO};
    gtime_t time0={0};
    obsd_t data0={{0}};
    eph_t  eph0 ={0,-1,-1};
    alm_t  alm0 ={0,-1};
    geph_t geph0={0,-1};
    seph_t seph0={0};
    sbsmsg_t sbsmsg0={0};
    lexmsg_t lexmsg0={0};
    int i,j,sys,ret=1;
    
    trace(3,"init_raw: format=%d\n",format);
    
    raw->time=time0;
    raw->ephsat=0;
    raw->sbsmsg=sbsmsg0;
    raw->msgtype[0]='\0';
    for (i=0;i<MAXRTKSAT;i++) {
        for (j=0;j<380;j++) raw->subfrm[i][j]=0;
        for (j=0;j<NFREQ+NEXOBS;j++) {
            raw->tobs [i][j]=time0;
            raw->lockt[i][j]=0.0;
            raw->halfc[i][j]=0;
        }
        raw->icpp[i]=raw->off[i]=raw->prCA[i]=raw->dpCA[i]=0.0;
    }
    for (i=0;i<MAXOBS;i++) raw->freqn[i]=0;
    raw->lexmsg=lexmsg0;
    raw->icpc=0.0;
    raw->nbyte=raw->len=0;
    raw->iod=raw->flag=raw->tbase=raw->outtype=0;
    raw->tod=-1;
    for (i=0;i<MAXRAWLEN;i++) raw->buff[i]=0;
    raw->opt[0]='\0';
    raw->format=-1;
    
    raw->obs.data =NULL;
    raw->obuf.data=NULL;
    raw->nav.eph  =NULL;
    raw->nav.alm  =NULL;
    raw->nav.geph =NULL;
    raw->nav.seph =NULL;
    raw->half_cyc =NULL;
    raw->rcv_data =NULL;
    
    if (!(raw->obs.data =(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
        !(raw->obuf.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
        !(raw->nav.eph  =(eph_t  *)malloc(sizeof(eph_t )*MAXRTKSAT))||
        !(raw->nav.alm  =(alm_t  *)malloc(sizeof(alm_t )*MAXRTKSAT))||
        !(raw->nav.geph =(geph_t *)malloc(sizeof(geph_t)*NSATGLO))||
        !(raw->nav.seph =(seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) {
        free_raw(raw);
        return 0;
    }
    raw->obs.n =0;
    raw->obuf.n=0;
    raw->nav.n =MAXRTKSAT;
    raw->nav.na=MAXRTKSAT;
    raw->nav.ng=NSATGLO;
    raw->nav.ns=NSATSBS*2;
    for (i=0;i<MAXOBS   ;i++) raw->obs.data [i]=data0;
    for (i=0;i<MAXOBS   ;i++) raw->obuf.data[i]=data0;
    for (i=0;i<MAXRTKSAT   ;i++) raw->nav.eph  [i]=eph0;
    for (i=0;i<MAXRTKSAT   ;i++) raw->nav.alm  [i]=alm0;
    for (i=0;i<NSATGLO  ;i++) raw->nav.geph [i]=geph0;
    for (i=0;i<NSATSBS*2;i++) raw->nav.seph [i]=seph0;
    for (i=0;i<MAXRTKSAT;i++) for (j=0;j<NFREQ;j++) {
        if (!(sys=satsys(i+1,NULL))) continue;
        raw->nav.lam[i][j]=sys==SYS_GLO?lam_glo[j]:lam_carr[j];
    }
    raw->sta.name[0]=raw->sta.marker[0]='\0';
    raw->sta.antdes[0]=raw->sta.antsno[0]='\0';
    raw->sta.rectype[0]=raw->sta.recver[0]=raw->sta.recsno[0]='\0';
    raw->sta.antsetup=raw->sta.itrf=raw->sta.deltype=0;
    for (i=0;i<3;i++) {
        raw->sta.pos[i]=raw->sta.del[i]=0.0;
    }
    raw->sta.hgt=0.0;
    
    /* initialize receiver dependent data */
    raw->format=format;
    switch (format) {
      //  case STRFMT_CMR : ret=init_cmr (raw); break;
        case STRFMT_RT17: ret=init_rt17(raw); break;
    }
    if (!ret) {
        free_raw(raw);
        return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %edx
movq %rdi, %rbx
leaq 0x366ff(%rip), %rsi     # 0x6d1b5
xorl %r15d, %r15d
movl $0x3, %edi
movl %edx, -0x2c(%rbp)
xorl %eax, %eax
callq 0x4ded0
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x70e40(%rbx)
movups %xmm0, 0x70e50(%rbx)
movups %xmm0, 0x70e60(%rbx)
movb $0x0, 0x70e70(%rbx)
leaq 0x70f70(%rbx), %rax
movq %rax, -0x38(%rbp)
movl $0x81860, %r14d         # imm = 0x81860
movq %rbx, %r13
xorl %r12d, %r12d
imulq $0x17c, %r12, %rdi      # imm = 0x17C
addq -0x38(%rbp), %rdi
movl $0x17c, %edx            # imm = 0x17C
xorl %esi, %esi
callq 0x8390
xorps %xmm0, %xmm0
movl $0x2, %eax
movq %r14, %rcx
movups %xmm0, (%r13,%rax,8)
movq $0x0, -0x38cc90(%rbx,%rcx,8)
movb $0x0, (%rbx,%rcx)
addq $0x2, %rax
incq %rcx
cmpq $0x8, %rax
jne 0x36b23
movq %r15, 0x81388(%rbx,%r12,8)
movq %r15, 0x80eb0(%rbx,%r12,8)
movq %r15, 0x809d0(%rbx,%r12,8)
movq %r15, 0x804f8(%rbx,%r12,8)
incq %r12
addq $0x30, %r13
addq $0x3, %r14
cmpq $0x9b, %r12
jne 0x36b01
xorps %xmm0, %xmm0
movups %xmm0, 0x81a61(%rbx)
movups %xmm0, 0x81a51(%rbx)
movups %xmm0, 0x81a41(%rbx)
movups %xmm0, 0x81a31(%rbx)
leaq 0x7f584(%rbx), %rdi
xorl %r14d, %r14d
movl $0xe8, %edx
xorl %esi, %esi
callq 0x8390
movq %r14, 0x80ea8(%rbx)
movq %r14, 0x81a74(%rbx)
movl $0x0, 0x81a8c(%rbx)
movq %r14, 0x81a84(%rbx)
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
movq %r15, 0x81a7c(%rbx)
leaq 0x81a90(%rbx), %rdi
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x8390
movb $0x0, 0x82a90(%rbx)
movl $0xffffffff, 0x82b98(%rbx) # imm = 0xFFFFFFFF
movq %r14, 0x1d28(%rbx)
movq %r14, 0x1d38(%rbx)
movq %r14, 0x1da8(%rbx)
movq %r14, 0x82b90(%rbx)
movq %r14, 0x82ba0(%rbx)
movl $0x1800, %edi           # imm = 0x1800
callq 0x8850
xorps %xmm0, %xmm0
movups %xmm0, 0x1d80(%rbx)
movq %r14, 0x1d90(%rbx)
movq %rax, 0x1d28(%rbx)
testq %rax, %rax
je 0x36f3c
movl $0x1800, %edi           # imm = 0x1800
callq 0x8850
movq %rax, 0x1d38(%rbx)
testq %rax, %rax
je 0x36f3c
leaq 0x1d80(%rbx), %r12
movl $0xae60, %edi           # imm = 0xAE60
callq 0x8850
movq %rax, (%r12)
testq %rax, %rax
je 0x36f3c
movl $0x43d0, %edi           # imm = 0x43D0
callq 0x8850
movq %rax, 0x1da8(%rbx)
testq %rax, %rax
je 0x36f3c
movl $0x1008, %edi           # imm = 0x1008
callq 0x8850
movq %rax, 0x1d88(%rbx)
testq %rax, %rax
je 0x36f3c
movl $0x1870, %edi           # imm = 0x1870
callq 0x8850
movq %rax, 0x1d90(%rbx)
testq %rax, %rax
je 0x36f3c
xorl %eax, %eax
movl %eax, 0x1d20(%rbx)
movl %eax, 0x1d30(%rbx)
movl $0x9b, %ecx
movl %ecx, 0x1d40(%rbx)
movl %ecx, 0x1d68(%rbx)
movl $0x1b, 0x1d48(%rbx)
movl $0x2e, 0x1d50(%rbx)
xorps %xmm0, %xmm0
movq 0x1d28(%rbx), %rcx
movups %xmm0, 0x50(%rcx,%rax)
movups %xmm0, 0x40(%rcx,%rax)
movups %xmm0, 0x30(%rcx,%rax)
movups %xmm0, 0x20(%rcx,%rax)
movups %xmm0, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
addq $0x60, %rax
cmpq $0x1800, %rax           # imm = 0x1800
jne 0x36d0d
xorl %eax, %eax
xorps %xmm0, %xmm0
movq 0x1d38(%rbx), %rcx
movups %xmm0, 0x50(%rcx,%rax)
movups %xmm0, 0x40(%rcx,%rax)
movups %xmm0, 0x30(%rcx,%rax)
movups %xmm0, 0x20(%rcx,%rax)
movups %xmm0, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
addq $0x60, %rax
cmpq $0x1800, %rax           # imm = 0x1800
jne 0x36d42
movl $0xc, %r14d
movq (%r12), %rax
leaq (%rax,%r14), %rdi
movq %r15, -0xc(%rax,%r14)
movl $0xffffffff, -0x4(%rax,%r14) # imm = 0xFFFFFFFF
movl $0x114, %edx            # imm = 0x114
xorl %esi, %esi
callq 0x8390
addq $0x120, %r14            # imm = 0x120
cmpq $0xae6c, %r14           # imm = 0xAE6C
jne 0x36d78
movl $0x8, %eax
xorps %xmm0, %xmm0
movq 0x1da8(%rbx), %rcx
movq %r15, -0x8(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
movups %xmm0, 0x10(%rcx,%rax)
movups %xmm0, 0x20(%rcx,%rax)
movups %xmm0, 0x30(%rcx,%rax)
movups %xmm0, 0x40(%rcx,%rax)
movups %xmm0, 0x50(%rcx,%rax)
movq $0x0, 0x60(%rcx,%rax)
addq $0x70, %rax
cmpq $0x43d8, %rax           # imm = 0x43D8
jne 0x36db2
movl $0x8, %r14d
movq 0x1d88(%rbx), %rdi
movq %r15, -0x8(%rdi,%r14)
addq %r14, %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x8390
addq $0x98, %r14
cmpq $0x1010, %r14           # imm = 0x1010
jne 0x36df6
xorl %r14d, %r14d
movq 0x1d90(%rbx), %rdi
addq %r14, %rdi
movl $0x88, %edx
xorl %esi, %esi
callq 0x8390
addq $0x88, %r14
cmpq $0x1870, %r14           # imm = 0x1870
jne 0x36e24
leaq 0x1fd8(%rbx), %r12
xorl %r15d, %r15d
incq %r15
xorl %r13d, %r13d
xorl %r14d, %r14d
movl %r15d, %edi
xorl %esi, %esi
callq 0x4dc2a
testl %eax, %eax
je 0x36e91
cmpl $0x4, %eax
jne 0x36e7d
leaq 0x360f9(%rip), %rax     # 0x6cf70
leaq (%rax,%r14,8), %rax
jmp 0x36e87
leaq 0x39d8c(%rip), %rax     # 0x70c10
addq %r13, %rax
movsd (%rax), %xmm0
movsd %xmm0, (%r12,%r13)
incq %r14
addq $0x8, %r13
cmpq $0x18, %r13
jne 0x36e5d
addq $0x18, %r12
cmpq $0x9b, %r15
jne 0x36e54
xorl %eax, %eax
movb %al, 0x70c78(%rbx)
movb %al, 0x70c38(%rbx)
movb %al, 0x70cf8(%rbx)
movb %al, 0x70cb8(%rbx)
movb %al, 0x70db8(%rbx)
movb %al, 0x70d78(%rbx)
movb %al, 0x70d38(%rbx)
movl $0x0, 0x70e00(%rbx)
movq %rax, 0x70df8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70e08(%rbx)
movq %rax, 0x70e18(%rbx)
movl $0xe1c4, %eax           # imm = 0xE1C4
movq $0x0, (%rbx,%rax,8)
incq %rax
cmpq $0xe1c7, %rax           # imm = 0xE1C7
jne 0x36efe
movq $0x0, 0x70e38(%rbx)
movl -0x2c(%rbp), %eax
movl %eax, 0x82b98(%rbx)
movl $0x1, %r15d
cmpl $0xc, %eax
jne 0x36f47
movq %rbx, %rdi
callq 0x3783d
testl %eax, %eax
jne 0x36f47
movq %rbx, %rdi
callq 0x36f59
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq