// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x100000, -0x30(%rbp)  # imm = 0x100000
movq $0x0, -0x38(%rbp)
cmpl $0x3, -0x8(%rbp)
jge 0x1246
movq 0x2e12(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xe40(%rip), %rsi       # 0x2030
movb $0x0, %al
callq 0x1060
movq 0x2dfa(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xe4b(%rip), %rsi       # 0x2053
movb $0x0, %al
callq 0x1060
movq 0x2de2(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xe72(%rip), %rsi       # 0x2092
movb $0x0, %al
callq 0x1060
movq 0x2dca(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xe79(%rip), %rsi       # 0x20b1
movb $0x0, %al
callq 0x1060
xorl %edi, %edi
callq 0x1080
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe83(%rip), %rsi       # 0x20d8
callq 0x1070
movq %rax, %rcx
movq %rcx, -0x18(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x12b3
movq 0x2d89(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x10a0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
leaq 0xe3b(%rip), %rsi       # 0x20db
movb $0x0, %al
callq 0x1060
callq 0x1030
movl (%rax), %edi
callq 0x1080
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0xe3b(%rip), %rsi       # 0x20fd
callq 0x1070
movq %rax, %rcx
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x1320
movq 0x2d1c(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x10a0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0xdf3(%rip), %rsi       # 0x2100
movb $0x0, %al
callq 0x1060
callq 0x1030
movl (%rax), %edi
callq 0x1080
movq 0x2cd1(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0xde2(%rip), %rsi       # 0x2123
movb $0x0, %al
callq 0x1060
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0x2d29(%rip), %rdi      # 0x4080
movl $0x1, %esi
callq 0x1040
movq %rax, %rcx
movq %rcx, -0x28(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x1424
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x2cf6(%rip), %rdi      # 0x4080
movl $0x1, %esi
callq 0x1090
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
je 0x13e1
movq 0x2c51(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x10a0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq %rax, %rcx
leaq 0xd61(%rip), %rsi       # 0x2139
movb $0x0, %al
callq 0x1060
jmp 0x1424
movq -0x28(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
andq $0xfffff, %rcx          # imm = 0xFFFFF
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x141f
movq 0x2bf2(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
shrq $0x14, %rdx
leaq 0xd39(%rip), %rsi       # 0x2151
movb $0x0, %al
callq 0x1060
jmp 0x1348
movq 0x2bcd(%rip), %rax      # 0x3ff8
movq %rax, -0x78(%rbp)
movq (%rax), %rdi
leaq 0xcfe(%rip), %rsi       # 0x2137
xorl %eax, %eax
callq 0x1060
movq -0x78(%rbp), %rax
movq (%rax), %rdi
movaps 0xbc2(%rip), %xmm1      # 0x2010
movq -0x38(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xbc1(%rip), %xmm1      # 0x2020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xb92(%rip), %xmm1      # 0x2008
divsd %xmm1, %xmm0
movq -0x38(%rbp), %rdx
leaq 0xcdd(%rip), %rsi       # 0x2162
movb $0x1, %al
callq 0x1060
movq -0x18(%rbp), %rdi
callq 0x1050
movq -0x20(%rbp), %rdi
callq 0x1050
xorl %edi, %edi
callq 0x1080