// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/extracters/rawcopy/RawCopy.c
// Function: main
int main(int argc, char **argv)
{
FILE *fin, *fout;
size_t bytesread, readsize = sizeof(buf), totalbytes = 0;

if (argc < 3)
    {
    fprintf(stderr, "Usage: RawCopy <infile> <outfile>\n");
    fprintf(stderr, "On Win32 environments, RAW devices have names for the format:\n");
    fprintf(stderr,"      CD Drives    \\\\.\\CdRom0\n");
    fprintf(stderr,"      Hard Drives  \\\\.\\PhysicalDrive0\n");
    exit(0);
    }
if (NULL == (fin = fopen(argv[1], "rb")))
    {
    fprintf(stderr, "Error Opening '%s' for input: %s\n", argv[1], strerror(errno));
    exit(errno);
    }
if (NULL == (fout = fopen(argv[2], "wb")))
    {
    fprintf(stderr, "Error Opening '%s' for output: %s\n", argv[2], strerror(errno));
    exit(errno);
    }
fprintf(stderr, "Copying '%s' to '%s'\n", argv[1], argv[2]);
while (0 != (bytesread = fread(buf, 1, readsize, fin)))
    {
    if (bytesread != fwrite(buf, 1, bytesread, fout))
        {
            fprintf(stderr, "Error Writing '%s': %s\n", argv[2], strerror(errno));
        break;
        }
    else
       totalbytes += bytesread;
    if (0 == (totalbytes%(1024*1024)))
        fprintf(stderr, "%6dMB Copied...\r", totalbytes/(1024*1024));
    }
fprintf(stderr, "\n");
fprintf(stderr, "Total Data: %6.2f MBytes (%d bytes)\n", totalbytes/(1024.0*1024.0), totalbytes);
fclose(fin);
fclose(fout);
 exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jle 0x136a
movq %rsi, %r15
movq 0x8(%rsi), %rdi
leaq 0xf02(%rip), %rsi       # 0x20e0
callq 0x1080
testq %rax, %rax
je 0x13d7
movq %rax, %rbx
movq 0x10(%r15), %rdi
leaq 0xf0b(%rip), %rsi       # 0x2105
callq 0x1080
movq %rax, %r14
movq 0x2def(%rip), %rax      # 0x3ff8
movq (%rax), %r12
testq %r14, %r14
je 0x1413
movq 0x8(%r15), %rdx
movq %r15, (%rsp)
movq 0x10(%r15), %rcx
leaq 0xf03(%rip), %rsi       # 0x212b
xorl %r15d, %r15d
movq %r12, %rdi
xorl %eax, %eax
callq 0x1070
leaq 0x2e44(%rip), %rdi      # 0x4080
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x1040
testq %rax, %rax
je 0x1300
movq %rax, %r12
leaq 0x2e1f(%rip), %r13      # 0x4080
leaq 0xef1(%rip), %rbp       # 0x2159
xorl %r15d, %r15d
movl $0x1, %esi
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x10a0
cmpq %rax, %r12
jne 0x12cb
addq %r12, %r15
testl $0xfffff, %r15d         # imm = 0xFFFFF
je 0x12ae
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %r13, %rdi
movq %rbx, %rcx
callq 0x1040
movq %rax, %r12
testq %rax, %rax
jne 0x126b
jmp 0x1300
movq 0x2d43(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq %r15, %rdx
shrq $0x14, %rdx
movq %rbp, %rsi
xorl %eax, %eax
callq 0x1070
jmp 0x128f
movq 0x2d26(%rip), %rax      # 0x3ff8
movq (%rax), %r12
movq (%rsp), %rax
movq 0x10(%rax), %r13
callq 0x1030
movl (%rax), %edi
callq 0x10b0
leaq 0xe51(%rip), %rsi       # 0x2141
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1070
movq 0x2cf1(%rip), %r12      # 0x3ff8
movq (%r12), %rsi
movl $0xa, %edi
callq 0x1060
movq %r15, %xmm1
punpckldq 0xcee(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movq (%r12), %rdi
subpd 0xcf2(%rip), %xmm1      # 0x2020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0xcee(%rip), %xmm0      # 0x2030
leaq 0xe21(%rip), %rsi       # 0x216a
movq %r15, %rdx
movb $0x1, %al
callq 0x1070
movq %rbx, %rdi
callq 0x1050
movq %r14, %rdi
callq 0x1050
xorl %edi, %edi
callq 0x1090
movq 0x2c87(%rip), %rbx      # 0x3ff8
movq (%rbx), %rcx
leaq 0xcbd(%rip), %rdi       # 0x2038
movl $0x22, %esi
movl $0x1, %edx
callq 0x10a0
movq (%rbx), %rcx
leaq 0xcc7(%rip), %rdi       # 0x205b
movl $0x3e, %esi
movl $0x1, %edx
callq 0x10a0
movq (%rbx), %rcx
leaq 0xced(%rip), %rdi       # 0x209a
movl $0x1e, %esi
movl $0x1, %edx
callq 0x10a0
movq (%rbx), %rcx
leaq 0xcf3(%rip), %rdi       # 0x20b9
movl $0x26, %esi
movl $0x1, %edx
callq 0x10a0
jmp 0x1363
movq 0x2c1a(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
movq 0x8(%r15), %r14
callq 0x1030
movq %rax, %r15
movl (%rax), %edi
callq 0x10b0
leaq 0xce8(%rip), %rsi       # 0x20e3
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1070
movl (%r15), %edi
callq 0x1090
movq 0x10(%r15), %rbx
callq 0x1030
movq %rax, %r14
movl (%rax), %edi
callq 0x10b0
leaq 0xcdb(%rip), %rsi       # 0x2108
movq %r12, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1070
movl (%r14), %edi
callq 0x1090