#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*/ dump_k_q(double *, double *, int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ load_pairing(int **, int, char *);
int /*<<< orphan*/ load_ranking(char *, int *, double **);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int N1, N2;
  double *R1 = NULL;
  double *R2 = NULL;
  int *pairing = NULL;
  if (argc < 4) {
    printf("Usage: %s <degs1> <degs2> <pairing>\n", argv[0]);
    exit(1);
  }
  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));
  load_pairing(&pairing, N1, argv[3]);
  dump_k_q(R1, R2, N1, pairing);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    11b0 <main+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <load_ranking@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <load_ranking@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11fe <main+0x9e>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    -0x30(%rbp),%rdi
call   1040 <load_pairing@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1060 <dump_k_q@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x3,%edi
jle    1204 <main+0x94>
mov    0x8(%r14),%rdi
lea    0x8(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1080 <load_ranking@plt>
mov    0x10(%r14),%rdi
lea    0xc(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1080 <load_ranking@plt>
mov    0x8(%rsp),%ebx
cmp    0xc(%rsp),%ebx
jne    121f <main+0xaf>
lea    0x0(,%rbx,4),%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    0x18(%r14),%rdx
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1050 <load_pairing@plt>
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    0x10(%rsp),%rcx
call   1070 <dump_k_q@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
mov    (%r14),%rsi
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xdff(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Usage: %s <degs1> <degs2> <pairing>\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 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** %9
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @load_ranking(i8* %21, i32* %5, double** %7)
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @load_ranking(i8* %25, i32* %6, double** %8)
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %18
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 4
%37 = trunc i64 %36 to i32
%38 = call i32* @malloc(i32 %37)
store i32* %38, i32** %9
%39 = load i32, i32* %5
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32 @load_pairing(i32** %9, i32 %39, i8* %42)
%44 = load double*, double** %7
%45 = load double*, double** %8
%46 = load i32, i32* %5
%47 = load i32*, i32** %9
%48 = call i32 @dump_k_q(double* %44, double* %45, i32 %46, i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Usage: %s <degs1> <degs2> <pairing>\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** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast double** %5 to i8*
store double* null, double** %5
%11 = bitcast double** %6 to i8*
store double* null, double** %6
%12 = bitcast i32** %7 to i8*
%13 = icmp slt i32 %0, 4
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 ([37 x i8], [37 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 1
%20 = load i8*, i8** %19
%21 = call i32 @load_ranking(i8* %20, i32* %3, double** %5)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @load_ranking(i8* %23, i32* %4, double** %6)
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp eq i32 %25, %26
br i1 %27, label %31, label %28
28: ; preds = %18
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18
%32 = shl i32 %25, 2
%33 = call i32* @malloc(i32 %32)
store i32* %33, i32** %7
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = call i32 @load_pairing(i32** %7, i32 %25, i8* %35)
%37 = load double*, double** %5
%38 = load double*, double** %6
%39 = load i32, i32* %3
%40 = load i32*, i32** %7
%41 = call i32 @dump_k_q(double* %37, double* %38, i32 %39, i32* %40)
ret i32 0
}