// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x32dda(%rip), %rsi     # 0x631b5
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x455bc
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x70f70(%rbx), %rax
leaq 0x10(%rbx), %rcx
leaq 0x7f670(%rbx), %rdx
leaq 0x81860(%rbx), %rsi
movups %xmm0, 0x70e40(%rbx)
movups %xmm0, 0x70e50(%rbx)
movups %xmm0, 0x70e60(%rbx)
movb $0x0, 0x70e70(%rbx)
cmpq $0x9b, %r15
je 0x304a5
movq $-0x17c, %rdi           # imm = 0xFE84
testq %rdi, %rdi
je 0x30448
movb $0x0, 0x17c(%rax,%rdi)
incq %rdi
jmp 0x30436
movq %rcx, %rdi
xorl %r8d, %r8d
cmpq $0x3, %r8
je 0x3046a
movups %xmm0, (%rdi)
andq $0x0, (%rdx,%r8,8)
movb $0x0, (%rsi,%r8)
incq %r8
addq $0x10, %rdi
jmp 0x3044e
andq $0x0, 0x81388(%rbx,%r15,8)
andq $0x0, 0x80eb0(%rbx,%r15,8)
andq $0x0, 0x809d0(%rbx,%r15,8)
andq $0x0, 0x804f8(%rbx,%r15,8)
incq %r15
addq $0x17c, %rax            # imm = 0x17C
addq $0x30, %rcx
addq $0x18, %rdx
addq $0x3, %rsi
jmp 0x30426
movl $0x81a31, %eax          # imm = 0x81A31
cmpq $0x81a71, %rax          # imm = 0x81A71
je 0x304bb
movb $0x0, (%rbx,%rax)
incq %rax
jmp 0x304aa
leaq 0x7f584(%rbx), %rdi
movl $0xe8, %edx
xorl %esi, %esi
callq 0x8390
andq $0x0, 0x80ea8(%rbx)
andq $0x0, 0x81a74(%rbx)
andl $0x0, 0x81a8c(%rbx)
andq $0x0, 0x81a84(%rbx)
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
movq %r15, 0x81a7c(%rbx)
movl $0x81a90, %eax          # imm = 0x81A90
cmpq $0x82a90, %rax          # imm = 0x82A90
je 0x30514
movb $0x0, (%rbx,%rax)
incq %rax
jmp 0x30503
movb $0x0, 0x82a90(%rbx)
orl $-0x1, 0x82b98(%rbx)
andq $0x0, 0x1d38(%rbx)
andq $0x0, 0x1da8(%rbx)
andq $0x0, 0x82b90(%rbx)
andq $0x0, 0x82ba0(%rbx)
movl $0x1800, %edi           # imm = 0x1800
callq 0x8830
andq $0x0, 0x1d90(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x1d80(%rbx)
movq %rax, 0x1d28(%rbx)
testq %rax, %rax
je 0x30854
movl $0x1800, %edi           # imm = 0x1800
callq 0x8830
movq %rax, 0x1d38(%rbx)
testq %rax, %rax
je 0x30854
leaq 0x1d80(%rbx), %r12
movl $0xae60, %edi           # imm = 0xAE60
callq 0x8830
movq %rax, (%r12)
testq %rax, %rax
je 0x30854
movl $0x43d0, %edi           # imm = 0x43D0
callq 0x8830
movq %rax, 0x1da8(%rbx)
testq %rax, %rax
je 0x30854
movl $0x1008, %edi           # imm = 0x1008
callq 0x8830
movq %rax, 0x1d88(%rbx)
testq %rax, %rax
je 0x30854
movl $0x1870, %edi           # imm = 0x1870
callq 0x8830
movq %rax, 0x1d90(%rbx)
testq %rax, %rax
je 0x30854
andl $0x0, 0x1d20(%rbx)
andl $0x0, 0x1d30(%rbx)
movl $0x9b, %eax
movl %eax, 0x1d40(%rbx)
movl %eax, 0x1d68(%rbx)
movl $0x1b, 0x1d48(%rbx)
movl $0x2e, 0x1d50(%rbx)
xorl %eax, %eax
xorps %xmm0, %xmm0
cmpq $0x1800, %rax           # imm = 0x1800
je 0x3065e
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
jmp 0x3062c
xorl %eax, %eax
xorps %xmm0, %xmm0
cmpq $0x1800, %rax           # imm = 0x1800
je 0x30695
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
jmp 0x30663
movl %r14d, -0x2c(%rbp)
pushq $0xc
popq %r14
cmpq $0xae6c, %r14           # imm = 0xAE6C
je 0x306ce
movq (%r12), %rax
leaq (%rax,%r14), %rdi
movq %r15, -0xc(%rax,%r14)
orl $-0x1, -0x4(%rax,%r14)
movl $0x114, %edx            # imm = 0x114
xorl %esi, %esi
callq 0x8390
addq $0x120, %r14            # imm = 0x120
jmp 0x3069d
pushq $0x8
popq %rax
xorps %xmm0, %xmm0
cmpq $0x43d8, %rax           # imm = 0x43D8
je 0x30711
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)
andq $0x0, 0x60(%rcx,%rax)
addq $0x70, %rax
jmp 0x306d4
pushq $0x8
popq %r14
cmpq $0x1010, %r14           # imm = 0x1010
je 0x30742
movq 0x1d88(%rbx), %rdi
movq %r15, -0x8(%rdi,%r14)
addq %r14, %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x8390
addq $0x98, %r14
jmp 0x30715
xorl %r14d, %r14d
cmpq $0x1870, %r14           # imm = 0x1870
je 0x3076d
movq 0x1d90(%rbx), %rdi
addq %r14, %rdi
movl $0x88, %edx
xorl %esi, %esi
callq 0x8390
addq $0x88, %r14
jmp 0x30745
leaq 0x1fd8(%rbx), %r12
xorl %r15d, %r15d
cmpq $0x9b, %r15
je 0x307d6
incq %r15
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpq $0x18, %r13
je 0x307d0
movl %r15d, %edi
xorl %esi, %esi
callq 0x45362
testl %eax, %eax
je 0x307c7
cmpl $0x4, %eax
jne 0x307ae
leaq 0x327c7(%rip), %rax     # 0x62f70
addq %r13, %rax
jmp 0x307bd
leaq (,%r14,8), %rax
addq 0x55803(%rip), %rax     # 0x85fc0
movsd (%rax), %xmm0
movsd %xmm0, (%r12,%r13)
incq %r14
addq $0x8, %r13
jmp 0x30789
addq $0x18, %r12
jmp 0x30777
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)
andl $0x0, 0x70e00(%rbx)
andq $0x0, 0x70df8(%rbx)
movl $0xe1c1, %eax           # imm = 0xE1C1
movl -0x2c(%rbp), %ecx
cmpq $0xe1c4, %rax           # imm = 0xE1C4
je 0x30831
andq $0x0, 0x18(%rbx,%rax,8)
andq $0x0, (%rbx,%rax,8)
incq %rax
jmp 0x30819
andq $0x0, 0x70e38(%rbx)
movl %ecx, 0x82b98(%rbx)
pushq $0x1
popq %r15
cmpl $0xc, %ecx
jne 0x3085f
movq %rbx, %rdi
callq 0x31092
testl %eax, %eax
jne 0x3085f
movq %rbx, %rdi
callq 0x30871
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq