#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getpid();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
char random();
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ srandom(scalar_t__);
int /*<<< orphan*/ stderr;
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  char buffer[(25 * 80 * 2)];
  char miscdata[4];
  int fd, c, i, j;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <src-vcs> <trg-vcs>\n", argv[0]);
    fprintf(stderr, "E.g.: %s /dev/vcc/a2 /dev/vcc/a3\n", argv[0]);
    return 1;
  }
  fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    perror(argv[1]);
    return 1;
  }
  read(fd, miscdata, 4);
  read(fd, buffer, (25 * 80 * 2));
  close(fd);
  srandom(time(NULL) + getpid());
  for (c = 0; c < (25 * 80 * 2) - 1; c += 2) {
    i = c + 1;
    j = c;
    buffer[i] ^= buffer[j] ^ c ^ random();
    if (c / (80 * 2) + 1 != time(NULL) % 25)
      buffer[i] &= 0x0f;
  }
  fd = open(argv[2], O_WRONLY);
  if (fd < 0) {
    perror(argv[2]);
    return 1;
  }
  write(fd, miscdata, 4);
  write(fd, buffer, (25 * 80 * 2));
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1207 <main+0x67>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe26(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe29(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140e <main+0x26e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0xfb8(%rbp)
cmpl   $0x0,-0xfb8(%rbp)
jge    1249 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    140e <main+0x26e>
mov    -0xfb8(%rbp),%edi
lea    -0xfb4(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0xfb8(%rbp),%edi
lea    -0xfb0(%rbp),%rsi
mov    $0xfa0,%edx
call   1070 <read@plt>
mov    -0xfb8(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
cltq
mov    %rax,-0xfd0(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0xfd0(%rbp),%rdi
add    %rax,%rdi
call   1030 <srandom@plt>
movl   $0x0,-0xfbc(%rbp)
cmpl   $0xf9f,-0xfbc(%rbp)
jge    138c <main+0x1ec>
mov    -0xfbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc0(%rbp)
mov    -0xfbc(%rbp),%eax
mov    %eax,-0xfc4(%rbp)
movslq -0xfc4(%rbp),%rax
movsbl -0xfb0(%rbp,%rax,1),%eax
ff
xor    -0xfbc(%rbp),%eax
mov    %eax,-0xfd8(%rbp)
mov    $0x0,%al
call   10a0 <random@plt>
mov    -0xfd8(%rbp),%edx
movsbl %al,%eax
xor    %eax,%edx
movslq -0xfc0(%rbp),%rax
movsbl -0xfb0(%rbp,%rax,1),%ecx
ff
xor    %edx,%ecx
mov    %cl,-0xfb0(%rbp,%rax,1)
mov    -0xfbc(%rbp),%eax
mov    $0xa0,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0xfd4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    $0x19,%ecx
cltd
idiv   %ecx
mov    -0xfd4(%rbp),%eax
cmp    %edx,%eax
je     1373 <main+0x1d3>
movslq -0xfc0(%rbp),%rax
movsbl -0xfb0(%rbp,%rax,1),%ecx
ff
and    $0xf,%ecx
mov    %cl,-0xfb0(%rbp,%rax,1)
jmp    1378 <main+0x1d8>
mov    -0xfbc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xfbc(%rbp)
jmp    12b4 <main+0x114>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c2d(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0xfb8(%rbp)
cmpl   $0x0,-0xfb8(%rbp)
jge    13ce <main+0x22e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    140e <main+0x26e>
mov    -0xfb8(%rbp),%edi
lea    -0xfb4(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0xfb8(%rbp),%edi
lea    -0xfb0(%rbp),%rsi
mov    $0xfa0,%edx
call   1040 <write@plt>
mov    -0xfb8(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfb0,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1297 <main+0xf7>
mov    0x8(%r14),%rdi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     131a <main+0x17a>
mov    %eax,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1070 <read@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xfa0,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1090 <time@plt>
movslq %eax,%rbx
xor    %eax,%eax
call   1050 <getpid@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <srandom@plt>
xor    %ebx,%ebx
jmp    1234 <main+0x94>
lea    0x2(%rbx),%rax
cmp    $0xf9d,%rbx
mov    %rax,%rbx
jae    12c7 <main+0x127>
movzbl 0x10(%rsp,%rbx,1),%r15d
xor    %bl,%r15b
xor    %eax,%eax
call   10a0 <random@plt>
mov    %eax,%r12d
xor    %r15b,%r12b
xor    0x11(%rsp,%rbx,1),%r12b
mov    %r12b,0x11(%rsp,%rbx,1)
movzwl %bx,%eax
imul   $0xcccd,%eax,%ebp
shr    $0x17,%ebp
add    $0x1,%ebp
xor    %edi,%edi
call   1090 <time@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    %ebp,%eax
je     1220 <main+0x80>
and    $0xf,%r12b
mov    %r12b,0x11(%rsp,%rbx,1)
jmp    1220 <main+0x80>
mov    0x2d3a(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xd56(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%rbx),%edi
mov    (%r14),%rdx
lea    0xd64(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    130a <main+0x16a>
mov    0x10(%r14),%rdi
mov    0x2cf6(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     1320 <main+0x180>
mov    %eax,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xfa0,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0xfb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r14),%rdi
jmp    1324 <main+0x184>
mov    0x10(%r14),%rdi
call   10c0 <perror@plt>
mov    $0x1,%eax
jmp    130a <main+0x16a>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Usage: %s <src-vcs> <trg-vcs>\0A\00"
@.str.1 = [34 x i8] c"E.g.: %s /dev/vcc/a2 /dev/vcc/a3\0A\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4000 x i8]
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %25
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %116
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %28, i32 %29)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @perror(i8* %36)
store i32 1, i32* %3
br label %116
38: ; preds = %25
%39 = load i32, i32* %8
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%41 = call i32 @read(i32 %39, i8* %40, i32 4)
%42 = load i32, i32* %8
%43 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 0
%44 = call i32 @read(i32 %42, i8* %43, i32 4000)
%45 = load i32, i32* %8
%46 = call i32 @close(i32 %45)
%47 = call i32 @time(i32* null)
%48 = sext i32 %47 to i64
%49 = call i64 (...) @getpid()
%50 = add nsw i64 %48, %49
%51 = call i32 @srandom(i64 %50)
store i32 0, i32* %9
br label %52
52: ; preds = %91, %38
%53 = load i32, i32* %9
%54 = icmp slt i32 %53, 3999
br i1 %54, label %55, label %94
55: ; preds = %52
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
%58 = load i32, i32* %9
store i32 %58, i32* %11
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = load i32, i32* %9
%65 = xor i32 %63, %64
%66 = call signext i8 (...) @random()
%67 = sext i8 %66 to i32
%68 = xor i32 %65, %67
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = xor i32 %73, %68
%75 = trunc i32 %74 to i8
store i8 %75, i8* %71
%76 = load i32, i32* %9
%77 = sdiv i32 %76, 160
%78 = add nsw i32 %77, 1
%79 = call i32 @time(i32* null)
%80 = srem i32 %79, 25
%81 = icmp ne i32 %78, %80
br i1 %81, label %82, label %90
82: ; preds = %55
%83 = load i32, i32* %10
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = and i32 %87, 15
%89 = trunc i32 %88 to i8
store i8 %89, i8* %85
br label %90
90: ; preds = %82, %55
br label %91
91: ; preds = %90
%92 = load i32, i32* %9
%93 = add nsw i32 %92, 2
store i32 %93, i32* %9
br label %52
94: ; preds = %52
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 2
%97 = load i8*, i8** %96
%98 = load i32, i32* @O_WRONLY
%99 = call i32 @open(i8* %97, i32 %98)
store i32 %99, i32* %8
%100 = load i32, i32* %8
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %94
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 2
%105 = load i8*, i8** %104
%106 = call i32 @perror(i8* %105)
store i32 1, i32* %3
br label %116
107: ; preds = %94
%108 = load i32, i32* %8
%109 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%110 = call i32 @write(i32 %108, i8* %109, i32 4)
%111 = load i32, i32* %8
%112 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 0
%113 = call i32 @write(i32 %111, i8* %112, i32 4000)
%114 = load i32, i32* %8
%115 = call i32 @close(i32 %114)
store i32 0, i32* %3
br label %116
116: ; preds = %107, %102, %33, %14
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Usage: %s <src-vcs> <trg-vcs>\0A\00"
@.str.1 = [34 x i8] c"E.g.: %s /dev/vcc/a2 /dev/vcc/a3\0A\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4000 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %70
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = tail call i32 @open(i8* %17, i32 %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %16
%23 = tail call i32 @perror(i8* %22)
br label %70
24: ; preds = %15
%25 = call i32 @read(i32 %19, i8* %6, i32 4)
%26 = call i32 @read(i32 %19, i8* %5, i32 4000)
%27 = tail call i32 @close(i32 %19)
%28 = tail call i32 @time(i32* null)
%29 = sext i32 %28 to i64
%30 = tail call i64 (...) @getpid()
%31 = add nsw i64 %30, %29
%32 = tail call i32 @srandom(i64 %31)
br label %33
33: ; preds = %24, %54
%34 = phi i64 [ 0, %24 ], [ %55, %54 ]
%35 = or i64 %34, 1
%36 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 %34
%37 = load i8, i8* %36
%38 = tail call signext i8 (...) @random()
%39 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 %35
%40 = load i8, i8* %39
%41 = trunc i64 %34 to i8
%42 = xor i8 %37, %41
%43 = xor i8 %42, %38
%44 = xor i8 %43, %40
store i8 %44, i8* %39
%45 = trunc i64 %34 to i16
%46 = udiv i16 %45, 160
%47 = add nuw nsw i16 %46, 1
%48 = zext i16 %47 to i32
%49 = tail call i32 @time(i32* null)
%50 = srem i32 %49, 25
%51 = icmp eq i32 %50, %48
br i1 %51, label %54, label %52
52: ; preds = %33
%53 = and i8 %44, 15
store i8 %53, i8* %39
br label %54
54: ; preds = %33, %52
%55 = add nuw nsw i64 %34, 2
%56 = icmp ult i64 %34, 3997
br i1 %56, label %33, label %57
57: ; preds = %54
%58 = getelementptr inbounds i8*, i8** %1, i64 2
%59 = load i8*, i8** %58
%60 = load i32, i32* @O_WRONLY
%61 = tail call i32 @open(i8* %59, i32 %60)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %57
%64 = load i8*, i8** %58
%65 = tail call i32 @perror(i8* %64)
br label %70
66: ; preds = %57
%67 = call i32 @write(i32 %61, i8* %6, i32 4)
%68 = call i32 @write(i32 %61, i8* %5, i32 4000)
%69 = tail call i32 @close(i32 %61)
br label %70
70: ; preds = %66, %63, %21, %8
%71 = phi i32 [ 1, %8 ], [ 1, %21 ], [ 1, %63 ], [ 0, %66 ]
ret i32 %71
}