#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int main(int argc, char **argv) {
  FILE *fp;
  int i, j, size;
  if (argc != 4) {
    printf("\nusage:\n%s <filename1> <filename2> <size>\n\n", argv[0]);
    exit(-1);
  }
  size = atoi(argv[3]);
  fp = fopen(argv[1], "w");
  fprintf(fp, "%d\n", size);
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++)
      fprintf(fp, "%d ", rand() / 1000000);
    fprintf(fp, "\n");
  }
  fclose(fp);
  fp = fopen(argv[2], "w");
  fprintf(fp, "%d\n", size);
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++)
      fprintf(fp, "%d ", rand() / 1000000);
    fprintf(fp, "\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11ad <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1269 <main+0xf9>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1249 <main+0xd9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1204 <main+0x94>
mov    -0x18(%rbp),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f1 <main+0x81>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    131e <main+0x1ae>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12fe <main+0x18e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x38(%rbp),%rdi
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xd49(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12b9 <main+0x149>
mov    -0x18(%rbp),%rdi
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12a6 <main+0x136>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x4,%edi
jne    12ee <main+0x16e>
mov    0x18(%r14),%rdi
call   1080 <atoi@plt>
mov    %eax,%r15d
mov    0x8(%r14),%rdi
lea    0xe7e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe71(%rip),%rsi
mov    %rax,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r15d,%r15d
jle    1235 <main+0xb5>
lea    0xe5c(%rip),%r13
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x431bde83,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x32,%rdx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x70>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r12d
cmp    %r15d,%r12d
jne    11e0 <main+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x10(%r14),%rdi
lea    0xde4(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xdd7(%rip),%rsi
mov    %rax,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r15d,%r15d
jle    12d5 <main+0x155>
lea    0xdc2(%rip),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x431bde83,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x32,%rdx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1290 <main+0x110>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r14d
cmp    %r15d,%r14d
jne    1280 <main+0x100>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%rsi
lea    0xd08(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"\0Ausage:\0A%s <filename1> <filename2> <size>\0A\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %9
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = load i32, i32* %9
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
store i32 0, i32* %7
br label %30
30: ; preds = %50, %18
%31 = load i32, i32* %7
%32 = load i32, i32* %9
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %53
34: ; preds = %30
store i32 0, i32* %8
br label %35
35: ; preds = %44, %34
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i32*, i32** %6
%41 = call i32 (...) @rand()
%42 = sdiv i32 %41, 1000000
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %39
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %35
47: ; preds = %35
%48 = load i32*, i32** %6
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %47
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %30
53: ; preds = %30
%54 = load i32*, i32** %6
%55 = call i32 @fclose(i32* %54)
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %59, i32** %6
%60 = load i32*, i32** %6
%61 = load i32, i32* %9
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 0, i32* %7
br label %63
63: ; preds = %83, %53
%64 = load i32, i32* %7
%65 = load i32, i32* %9
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %86
67: ; preds = %63
store i32 0, i32* %8
br label %68
68: ; preds = %77, %67
%69 = load i32, i32* %8
%70 = load i32, i32* %9
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %80
72: ; preds = %68
%73 = load i32*, i32** %6
%74 = call i32 (...) @rand()
%75 = sdiv i32 %74, 1000000
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %72
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %68
80: ; preds = %68
%81 = load i32*, i32** %6
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %83
83: ; preds = %80
%84 = load i32, i32* %7
%85 = add nsw i32 %84, 1
store i32 %85, i32* %7
br label %63
86: ; preds = %63
%87 = load i32*, i32** %6
%88 = call i32 @fclose(i32* %87)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"\0Ausage:\0A%s <filename1> <filename2> <size>\0A\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%16 = icmp sgt i32 %11, 0
br i1 %16, label %17, label %30
17: ; preds = %8, %26
%18 = phi i32 [ %28, %26 ], [ 0, %8 ]
br label %19
19: ; preds = %17, %19
%20 = phi i32 [ %24, %19 ], [ 0, %17 ]
%21 = tail call i32 (...) @rand()
%22 = sdiv i32 %21, 1000000
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %20, 1
%25 = icmp eq i32 %24, %11
br i1 %25, label %26, label %19
26: ; preds = %19
%27 = tail call i32 @fputc(i32 10, i32* %14)
%28 = add nuw nsw i32 %18, 1
%29 = icmp eq i32 %28, %11
br i1 %29, label %30, label %17
30: ; preds = %26, %8
%31 = tail call i32 @fclose(i32* %14)
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br i1 %16, label %36, label %49
36: ; preds = %30, %45
%37 = phi i32 [ %47, %45 ], [ 0, %30 ]
br label %38
38: ; preds = %36, %38
%39 = phi i32 [ %43, %38 ], [ 0, %36 ]
%40 = tail call i32 (...) @rand()
%41 = sdiv i32 %40, 1000000
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i32 %39, 1
%44 = icmp eq i32 %43, %11
br i1 %44, label %45, label %38
45: ; preds = %38
%46 = tail call i32 @fputc(i32 10, i32* %34)
%47 = add nuw nsw i32 %37, 1
%48 = icmp eq i32 %47, %11
br i1 %48, label %49, label %36
49: ; preds = %45, %30
%50 = tail call i32 @fclose(i32* %34)
ret i32 0
}