// File: /workspace/github_cpp_makefile_star2_O1/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
cmpb $0x65, (%rax)
jne 0x3703
movq 0x10(%r14), %rsi
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x3958
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x9d4(%rip), %rsi       # 0x406c
leaq 0x9d8(%rip), %rdx       # 0x4077
leaq 0x50(%rsp), %rdi
callq 0x3996
leaq 0x490(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movl $0xc8, %ecx
movl $0xd0, %r8d
callq 0x2e80
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x36e2
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2150
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3703
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x8(%r14), %rax
cmpb $0x6d, (%rax)
sete %al
cmpq $0xc5121, %rbx          # imm = 0xC5121
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x377c
leaq 0x947(%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 0x3761
movl %ebp, %edi
callq 0x2230
movq 0x8(%r14), %rax
cmpb $0x64, (%rax)
jne 0x38a1
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 0x37d3
movq %r12, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x98(%rsp)
jmp 0x37de
movq %r14, %rdi
movq %r15, %rdx
callq 0x3a26
incq %r12
cmpq $0xc5120, %r12          # imm = 0xC5120
jne 0x37ab
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x872(%rip), %rsi       # 0x406c
leaq 0x876(%rip), %rdx       # 0x4077
leaq 0x30(%rsp), %rdi
callq 0x3996
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x85c(%rip), %rsi       # 0x4078
leaq 0x862(%rip), %rdx       # 0x4085
leaq 0x10(%rsp), %rdi
callq 0x3996
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 0x2a34
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x386d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x3884
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x38a1
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 0x38d2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x38d2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x3932
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x3932
jmp 0x392f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x390c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x390c
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x394f
movq 0x80(%rsp), %rsi
incq %rsi
jmp 0x394a
movq %rax, %rbx
jmp 0x394f
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x394f
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x21e0
nop