#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 */
double atof(char *);
int /*<<< orphan*/ dump_pairing(int *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ load_ranking(char *, int *, double **);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ select_pairing(int *, int, int, char **, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ tune_qnn_adaptive(double *, double *, int, int *, double,
                                     double, double);
int main(int argc, char *argv[]) {
  int N1, N2;
  double *R1 = NULL;
  double *R2 = NULL;
  double eps, beta, mu_target;
  int *pairing = NULL;
  srand(time(NULL));
  if (argc < 6) {
    printf("Usage: %s <degs1> <degs2> <mu> <eps> <beta> [RND|NAT|INV]\n",
           argv[0]);
    exit(1);
  }
  mu_target = atof(argv[3]);
  eps = atof(argv[4]);
  beta = atof(argv[5]);
  load_ranking(argv[1], &N1, &R1);
  load_ranking(argv[2], &N2, &R2);
  if (N1 != N2) {
    printf("Error!!!! The two files must have the same number of lines!!!! "
           "Exiting...\n");
    exit(1);
  }
  pairing = malloc(N1 * sizeof(int));
  select_pairing(pairing, N1, argc, argv, 6);
  tune_qnn_adaptive(R1, R2, N1, pairing, eps, beta, mu_target);
  dump_pairing(pairing, N1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x48(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x6,-0x4(%rbp)
jge    1200 <main+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   10b0 <load_ranking@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   10b0 <load_ranking@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1284 <main+0xe4>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x6,%r8d
call   1080 <select_pairing@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x48(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
call   1060 <tune_qnn_adaptive@plt>
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <dump_pairing@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmp    $0x5,%r14d
jle    12b1 <main+0x101>
mov    0x18(%r15),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x30(%rsp)
mov    0x20(%r15),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x28(%r15),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x20(%rsp)
mov    0x8(%r15),%rdi
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   10c0 <load_ranking@plt>
mov    0x10(%r15),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   10c0 <load_ranking@plt>
mov    0x8(%rsp),%ebp
cmp    0xc(%rsp),%ebp
jne    12cc <main+0x11c>
lea    0x0(,%rbp,4),%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15,%rcx
mov    $0x6,%r8d
call   1090 <select_pairing@plt>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    %rbx,%rcx
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
call   1070 <tune_qnn_adaptive@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <dump_pairing@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%rsi
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd68(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"Usage: %s <degs1> <degs2> <mu> <eps> <beta> [RND|NAT|INV]\0A\00"
@.str.1 = [75 x i8] c"Error!!!! The two files must have the same number of lines!!!! Exiting...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store double* null, double** %7
store double* null, double** %8
store i32* null, i32** %12
%13 = call i32 @time(i32* null)
%14 = call i32 @srand(i32 %13)
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 6
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call double @atof(i8* %26)
store double %27, double* %11
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 4
%30 = load i8*, i8** %29
%31 = call double @atof(i8* %30)
store double %31, double* %9
%32 = load i8**, i8*** %4
%33 = getelementptr inbounds i8*, i8** %32, i64 5
%34 = load i8*, i8** %33
%35 = call double @atof(i8* %34)
store double %35, double* %10
%36 = load i8**, i8*** %4
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @load_ranking(i8* %38, i32* %5, double** %7)
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @load_ranking(i8* %42, i32* %6, double** %8)
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %23
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %23
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = mul i64 %52, 4
%54 = trunc i64 %53 to i32
%55 = call i32* @malloc(i32 %54)
store i32* %55, i32** %12
%56 = load i32*, i32** %12
%57 = load i32, i32* %5
%58 = load i32, i32* %3
%59 = load i8**, i8*** %4
%60 = call i32 @select_pairing(i32* %56, i32 %57, i32 %58, i8** %59, i32 6)
%61 = load double*, double** %7
%62 = load double*, double** %8
%63 = load i32, i32* %5
%64 = load i32*, i32** %12
%65 = load double, double* %9
%66 = load double, double* %10
%67 = load double, double* %11
%68 = call i32 @tune_qnn_adaptive(double* %61, double* %62, i32 %63, i32* %64, double %65, double %66, double %67)
%69 = load i32*, i32** %12
%70 = load i32, i32* %5
%71 = call i32 @dump_pairing(i32* %69, i32 %70)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"Usage: %s <degs1> <degs2> <mu> <eps> <beta> [RND|NAT|INV]\0A\00"
@str = [74 x i8] c"Error!!!! The two files must have the same number of lines!!!! Exiting...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast double** %5 to i8*
store double* null, double** %5
%10 = bitcast double** %6 to i8*
store double* null, double** %6
%11 = tail call i32 @time(i32* null)
%12 = tail call i32 @srand(i32 %11)
%13 = icmp slt i32 %0, 6
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call double @atof(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 4
%23 = load i8*, i8** %22
%24 = tail call double @atof(i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 5
%26 = load i8*, i8** %25
%27 = tail call double @atof(i8* %26)
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @load_ranking(i8* %29, i32* %3, double** %5)
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @load_ranking(i8* %32, i32* %4, double** %6)
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = icmp eq i32 %34, %35
br i1 %36, label %40, label %37
37: ; preds = %18
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %18
%41 = shl i32 %34, 2
%42 = call i32* @malloc(i32 %41)
%43 = call i32 @select_pairing(i32* %42, i32 %34, i32 %0, i8** %1, i32 6)
%44 = load double*, double** %5
%45 = load double*, double** %6
%46 = load i32, i32* %3
%47 = call i32 @tune_qnn_adaptive(double* %44, double* %45, i32 %46, i32* %42, double %24, double %27, double %21)
%48 = load i32, i32* %3
%49 = call i32 @dump_pairing(i32* %42, i32 %48)
ret i32 0
}