// File: /workspace/github_cpp_makefile_star2_O3/NinjaDevelper[P]ReedSolomon/cxx/main.cpp
// Function: main
int main(int argc,char *argv[]){
    ReedSolomon rs;
 
    int fin=open(argv[2],O_RDONLY);
    long size=lseek(fin,0,SEEK_END);
    lseek(fin,0,SEEK_SET);
    close(fin);

    if(argv[1][0]=='e'){
        rs.encodeFile(argv[2],"encoded.dat",200,208);
    }
    if(argv[1][0]=='m'){
        if(size>500000+1024*300){
            //embed sequential error
	    fin=open("encoded.dat",O_RDWR);
	    lseek(fin,FROM,SEEK_END);
	    char buf[1024]={};
	    for(int i=0;i<COUNT;i++){
	        write(fin,buf,1024);
	    }
	    close(fin);
        }
    }
    if(argv[1][0]=='d'){
	vector<long> loc;
	for(int i=0;i<COUNT*1024;i++){
	    loc.push_back(i+500000);
    	}
        rs.decodeFile("encoded.dat","recovered.dat",200,208,size,loc);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x790, %rsp            # imm = 0x790
movq %rsi, %r14
leaq 0x490(%rsp), %rdi
callq 0x236c
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2100
movl %eax, %ebp
movl %eax, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2210
movq %rax, %rbx
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2210
movl %ebp, %edi
callq 0x2230
movq 0x8(%r14), %rax
movb (%rax), %al
cmpb $0x65, %al
jne 0x3742
movq 0x10(%r14), %rsi
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x3992
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x99b(%rip), %rsi       # 0x406c
leaq 0x99f(%rip), %rdx       # 0x4077
leaq 0x50(%rsp), %rdi
callq 0x39d0
leaq 0x490(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movl $0xc8, %ecx
movl $0xd0, %r8d
callq 0x2eb6
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x371b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2150
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x373c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x8(%r14), %rax
movb (%rax), %al
cmpb $0x6d, %al
sete %cl
cmpq $0xc5121, %rbx          # imm = 0xC5121
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x37bc
leaq 0x90d(%rip), %rdi       # 0x406c
movl $0x2, %esi
xorl %eax, %eax
callq 0x2100
movl %eax, %ebp
movl $0x7a120, %esi          # imm = 0x7A120
movl %eax, %edi
movl $0x2, %edx
callq 0x2210
leaq 0x90(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x20b0
movl $0x12c, %r12d           # imm = 0x12C
movl $0x400, %edx            # imm = 0x400
movl %ebp, %edi
movq %r15, %rsi
callq 0x2060
decl %r12d
jne 0x379b
movl %ebp, %edi
callq 0x2230
movq 0x8(%r14), %rax
movb (%rax), %al
cmpb $0x64, %al
jne 0x38dc
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %r14
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x7a120, %r12d         # imm = 0x7A120
leaq 0x8(%rsp), %r15
movq %r12, 0x8(%rsp)
movq 0x98(%rsp), %rsi
cmpq 0xa0(%rsp), %rsi
je 0x380e
movq %r12, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98(%rsp)
jmp 0x3819
movq %r14, %rdi
movq %r15, %rdx
callq 0x3a66
incq %r12
cmpq $0xc5120, %r12          # imm = 0xC5120
jne 0x37e6
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x837(%rip), %rsi       # 0x406c
leaq 0x83b(%rip), %rdx       # 0x4077
leaq 0x30(%rsp), %rdi
callq 0x39d0
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x821(%rip), %rsi       # 0x4078
leaq 0x827(%rip), %rdx       # 0x4085
leaq 0x10(%rsp), %rdi
callq 0x39d0
movq %r14, (%rsp)
leaq 0x490(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movl $0xc8, %ecx
movl $0xd0, %r8d
movq %rbx, %r9
callq 0x2a4e
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x38a8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x38bf
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x38dc
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
xorl %eax, %eax
addq $0x790, %rsp            # imm = 0x790
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x390d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x390d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x396d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x396d
jmp 0x396a
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x3947
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x3947
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x398a
movq 0x80(%rsp), %rsi
incq %rsi
jmp 0x3985
movq %rax, %rbx
jmp 0x398a
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x398a
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x21e0