#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 atoi(char *);
int /*<<< orphan*/ fillArray(int *, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sortArray(int *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ writeArray(int *, int, char *);
int /*<<< orphan*/ writeArrayBin(int *, int, char *);
int main(int argc, char **argv) {
  int n1, n2;
  int *v1, *v2;
  if (argc != 3) {
    fprintf(stderr, "Wrong number of parameters. Syntax: %s n1 n2\n", argv[0]);
    return -1;
  }
  n1 = atoi(argv[1]);
  n2 = atoi(argv[2]);
  v1 = (int *)malloc(n1 * sizeof(int));
  v2 = (int *)malloc(n2 * sizeof(int));
  fillArray(v1, n1, 10, 100);
  fillArray(v2, n2, 20, 100);
  sortArray(v1, n1);
  sortArray(v2, n2);
  writeArray(v1, n1, "fv1.txt");
  writeArray(v2, n2, "fv2.txt");
  writeArrayBin(v1, n1, "fv1.b");
  writeArrayBin(v2, n2, "fv2.b");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b8 <main+0x48>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1295 <main+0x125>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0xa,%edx
mov    $0x64,%ecx
call   1030 <fillArray@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x14,%edx
mov    $0x64,%ecx
call   1030 <fillArray@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <sortArray@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <sortArray@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xdde(%rip),%rdx
call   1040 <writeArray@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    0xdd3(%rip),%rdx
call   1040 <writeArray@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xdc8(%rip),%rdx
call   1050 <writeArrayBin@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    0xdbb(%rip),%rdx
call   1050 <writeArrayBin@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1249 <main+0xd9>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r13d
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r13,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r15
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0xa,%edx
mov    $0x64,%ecx
call   1030 <fillArray@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    $0x14,%edx
mov    $0x64,%ecx
call   1030 <fillArray@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   1060 <sortArray@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1060 <sortArray@plt>
lea    0xe2a(%rip),%rdx
mov    %r15,%rdi
mov    %r13d,%esi
call   1040 <writeArray@plt>
lea    0xe20(%rip),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
call   1040 <writeArray@plt>
lea    0xe16(%rip),%rdx
mov    %r15,%rdi
mov    %r13d,%esi
call   1050 <writeArrayBin@plt>
lea    0xe0a(%rip),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <writeArrayBin@plt>
xor    %eax,%eax
jmp    1266 <main+0xf6>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xda4(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"Wrong number of parameters. Syntax: %s n1 n2\0A\00"
@.str.1 = [8 x i8] c"fv1.txt\00"
@.str.2 = [8 x i8] c"fv2.txt\00"
@.str.3 = [6 x i8] c"fv1.b\00"
@.str.4 = [6 x i8] c"fv2.b\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, 3
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 -1, i32* %3
br label %63
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 4
%30 = trunc i64 %29 to i32
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i32*
store i32* %32, i32** %8
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 4
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i32*
store i32* %38, i32** %9
%39 = load i32*, i32** %8
%40 = load i32, i32* %6
%41 = call i32 @fillArray(i32* %39, i32 %40, i32 10, i32 100)
%42 = load i32*, i32** %9
%43 = load i32, i32* %7
%44 = call i32 @fillArray(i32* %42, i32 %43, i32 20, i32 100)
%45 = load i32*, i32** %8
%46 = load i32, i32* %6
%47 = call i32 @sortArray(i32* %45, i32 %46)
%48 = load i32*, i32** %9
%49 = load i32, i32* %7
%50 = call i32 @sortArray(i32* %48, i32 %49)
%51 = load i32*, i32** %8
%52 = load i32, i32* %6
%53 = call i32 @writeArray(i32* %51, i32 %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%54 = load i32*, i32** %9
%55 = load i32, i32* %7
%56 = call i32 @writeArray(i32* %54, i32 %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32*, i32** %8
%58 = load i32, i32* %6
%59 = call i32 @writeArrayBin(i32* %57, i32 %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%60 = load i32*, i32** %9
%61 = load i32, i32* %7
%62 = call i32 @writeArrayBin(i32* %60, i32 %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %63
63: ; preds = %18, %12
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"Wrong number of parameters. Syntax: %s n1 n2\0A\00"
@.str.1 = [8 x i8] c"fv1.txt\00"
@.str.2 = [8 x i8] c"fv2.txt\00"
@.str.3 = [6 x i8] c"fv1.b\00"
@.str.4 = [6 x i8] c"fv2.b\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %29
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = shl i32 %11, 2
%16 = tail call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
%18 = shl i32 %14, 2
%19 = tail call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
%21 = tail call i32 @fillArray(i32* %17, i32 %11, i32 10, i32 100)
%22 = tail call i32 @fillArray(i32* %20, i32 %14, i32 20, i32 100)
%23 = tail call i32 @sortArray(i32* %17, i32 %11)
%24 = tail call i32 @sortArray(i32* %20, i32 %14)
%25 = tail call i32 @writeArray(i32* %17, i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @writeArray(i32* %20, i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @writeArrayBin(i32* %17, i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @writeArrayBin(i32* %20, i32 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %8, %4
%30 = phi i32 [ -1, %4 ], [ 0, %8 ]
ret i32 %30
}