// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
movq %rsi, %r14
leaq 0x4a8(%rsp), %rdi
callq 0x234c
movq 0x10(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2110
movl %eax, %ebp
pushq $0x2
popq %rdx
movl %eax, %edi
xorl %esi, %esi
callq 0x2220
movq %rax, %rbx
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
movl %ebp, %edi
callq 0x2240
movq 0x8(%r14), %rax
movb (%rax), %al
cmpb $0x65, %al
jne 0x3600
movq 0x10(%r14), %rsi
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x37b2
leaq 0xabd(%rip), %rsi       # 0x406c
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x37b2
leaq 0x4a8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movl $0xc8, %ecx
movl $0xd0, %r8d
callq 0x2cb0
leaq 0x60(%rsp), %rdi
callq 0x20a0
leaq 0x80(%rsp), %rdi
callq 0x20a0
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 0x367d
leaq 0xa4f(%rip), %rdi       # 0x406c
pushq $0x2
popq %r15
movl %r15d, %esi
xorl %eax, %eax
callq 0x2110
movl %eax, %ebp
movl $0x7a120, %esi          # imm = 0x7A120
movl %eax, %edi
movl %r15d, %edx
callq 0x2220
leaq 0xa0(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x20c0
movl $0x12c, %r12d           # imm = 0x12C
subl $0x1, %r12d
jb 0x3670
movl $0x400, %edx            # imm = 0x400
movl %ebp, %edi
movq %r15, %rsi
callq 0x2060
jmp 0x3659
movl %ebp, %edi
callq 0x2240
movq 0x8(%r14), %rax
movb (%rax), %al
cmpb $0x64, %al
jne 0x373f
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %r14
andq $0x0, 0x10(%r14)
movaps %xmm0, (%r14)
movl $0x4b000, %r12d         # imm = 0x4B000
xorl %r13d, %r13d
leaq 0x18(%rsp), %r15
subq $0x1, %r12
jb 0x36c9
leaq 0x7a120(%r13), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x38b8
incq %r13
jmp 0x36a7
leaq 0x99c(%rip), %rsi       # 0x406c
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x37b2
leaq 0x992(%rip), %rsi       # 0x4078
leaq 0x20(%rsp), %rdi
leaq 0x17(%rsp), %rdx
callq 0x37b2
movq %r14, (%rsp)
leaq 0x4a8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movl $0xc8, %ecx
movl $0xd0, %r8d
movq %rbx, %r9
callq 0x2922
leaq 0x20(%rsp), %rdi
callq 0x20a0
leaq 0x40(%rsp), %rdi
callq 0x20a0
leaq 0xa0(%rsp), %rdi
callq 0x3884
xorl %eax, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20a0
jmp 0x3765
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x20a0
jmp 0x379c
jmp 0x3799
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x20a0
jmp 0x3785
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x20a0
jmp 0x37a9
movq %rax, %rbx
jmp 0x37a9
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3884
movq %rbx, %rdi
callq 0x21f0
nop