#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 */
scalar_t__ allocate_memory_for_ordered_list(long, long **);
scalar_t__ allocate_memory_for_profit(long, int, double ***);
scalar_t__ allocate_memory_for_weights(long, int, long ***);
void *atoi(char *);
int /*<<< orphan*/ check_methods(long, int, long, long *, long **, double **);
scalar_t__ create_file_of_profit(char *, long, int);
scalar_t__ create_file_of_weights(char *, long, int);
scalar_t__ create_file_ordered_list(char *, long);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ print_ordered_list_values(long, long *);
int /*<<< orphan*/ print_precincts_weight_profit(long, int, long **, double **,
                                                 long *);
int /*<<< orphan*/ print_profit_values(long, int, double **);
int /*<<< orphan*/ print_weights_values(long, int, long **);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read_file_of_profit(char *, long, int, double **);
scalar_t__ read_file_of_weights(char *, long, int, long **);
scalar_t__ read_file_ordered_list(char *, long, long *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  long budget;
  long max_precincts;
  int max_quality_layers;
  long **weights;
  double **profit;
  long *ordered_list;
  int i, j;
  if (argc < 4) {
    printf("Usage: %s <max_precincts> <max_quality_layers> <budget>\n",
           argv[0]);
    exit(0);
  }
  max_precincts = atoi(argv[1]);
  if (max_precincts <= 0) {
    printf("The max number of precincts must be a positive integer\n");
    exit(0);
  }
  max_quality_layers = atoi(argv[2]);
  if (max_quality_layers <= 0) {
    printf("The max number of quality layers must be a positive integer\n");
    exit(0);
  }
  budget = atoi(argv[3]);
  if (budget <= 0) {
    printf("The budget must be a positive integer\n");
    exit(0);
  }
  srand(time(NULL));
  if (allocate_memory_for_weights(max_precincts, max_quality_layers,
                                  &weights) <= 0) {
    printf("Error allocating memory for weights.\n");
    exit(1);
  }
  if (allocate_memory_for_profit(max_precincts, max_quality_layers, &profit) <=
      0) {
    printf("Error allocating memory for profit.\n");
    exit(1);
  }
  if (allocate_memory_for_ordered_list(max_precincts, &ordered_list) <= 0) {
    printf("Error allocating memory for ordered list.\n");
    exit(1);
  }
  if (create_file_of_weights("weights.txt", max_precincts,
                             max_quality_layers) <= 0) {
    printf("Error creating the file of weights: %s\n", "weights.txt");
    exit(1);
  }
  if (read_file_of_weights("weights.txt", max_precincts, max_quality_layers,
                           weights) <= 0) {
    printf("Error reading the file of weights: %s\n", "weights.txt");
    exit(1);
  }
  if (create_file_of_profit("profit.txt", max_precincts, max_quality_layers) <=
      0) {
    printf("Error creating the file of profit: %s\n", "profit.txt");
    exit(1);
  }
  if (read_file_of_profit("profit.txt", max_precincts, max_quality_layers,
                          profit) <= 0) {
    printf("Error reading the file of profit: %s\n", "profit.txt");
    exit(1);
  }
  if (create_file_ordered_list("ordered_list.txt", max_precincts) <= 0) {
    printf("Error creating the file for the ordered list of precincts: %s\n",
           "ordered_list.txt");
    exit(1);
  }
  if (read_file_ordered_list("ordered_list.txt", max_precincts, ordered_list) <=
      0) {
    printf("Error reading the file for the ordered list of precincts: %s\n",
           "ordered_list.txt");
    exit(1);
  }
  if (0) {
    print_weights_values(max_precincts, max_quality_layers, weights);
    print_profit_values(max_precincts, max_quality_layers, profit);
    print_ordered_list_values(max_precincts, ordered_list);
    print_precincts_weight_profit(max_precincts, max_quality_layers, weights,
                                  profit, ordered_list);
  }
  check_methods(max_precincts, max_quality_layers, budget, ordered_list,
                weights, profit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    122c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jg     125d <main+0x6d>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     128c <main+0x9c>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     12bd <main+0xcd>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1090 <allocate_memory_for_weights@plt>
cmp    $0x0,%rax
jg     12ff <main+0x10f>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1060 <allocate_memory_for_profit@plt>
cmp    $0x0,%rax
jg     1331 <main+0x141>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1100 <allocate_memory_for_ordered_list@plt>
cmp    $0x0,%rax
jg     1360 <main+0x170>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xddd(%rip),%rdi
call   1110 <create_file_of_weights@plt>
cmp    $0x0,%rax
jg     139c <main+0x1ac>
lea    0xdd3(%rip),%rdi
lea    0xdc0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xd9d(%rip),%rdi
call   10f0 <read_file_of_weights@plt>
cmp    $0x0,%rax
jg     13dc <main+0x1ec>
lea    0xdbb(%rip),%rdi
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xdbc(%rip),%rdi
call   10a0 <create_file_of_profit@plt>
cmp    $0x0,%rax
jg     1418 <main+0x228>
lea    0xdb1(%rip),%rdi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x38(%rbp),%rcx
lea    0xd7c(%rip),%rdi
call   10c0 <read_file_of_profit@plt>
cmp    $0x0,%rax
jg     1458 <main+0x268>
lea    0xd98(%rip),%rdi
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
lea    0xd9b(%rip),%rdi
call   1080 <create_file_ordered_list@plt>
cmp    $0x0,%rax
jg     1491 <main+0x2a1>
lea    0xd96(%rip),%rdi
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xd5e(%rip),%rdi
call   1050 <read_file_ordered_list@plt>
cmp    $0x0,%rax
jg     14ce <main+0x2de>
lea    0xd98(%rip),%rdi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1040 <check_methods@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jle    137e <main+0x17e>
mov    0x8(%rbx),%rdi
call   10e0 <atoi@plt>
test   %rax,%rax
jle    1396 <main+0x196>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
call   10e0 <atoi@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    139f <main+0x19f>
mov    0x18(%rbx),%rdi
call   10e0 <atoi@plt>
test   %rax,%rax
jle    13a8 <main+0x1a8>
mov    %rax,%r15
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
call   10a0 <allocate_memory_for_weights@plt>
test   %rax,%rax
jle    13bb <main+0x1bb>
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <allocate_memory_for_profit@plt>
test   %rax,%rax
jle    13c4 <main+0x1c4>
mov    %rsp,%rsi
mov    %r12,%rdi
call   1110 <allocate_memory_for_ordered_list@plt>
test   %rax,%rax
jle    13cd <main+0x1cd>
lea    0xd88(%rip),%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1120 <create_file_of_weights@plt>
test   %rax,%rax
jle    13e3 <main+0x1e3>
mov    0x10(%rsp),%rcx
lea    0xd68(%rip),%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1100 <read_file_of_weights@plt>
test   %rax,%rax
jle    13ec <main+0x1ec>
lea    0xda8(%rip),%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   10b0 <create_file_of_profit@plt>
test   %rax,%rax
jle    13fc <main+0x1fc>
mov    0x8(%rsp),%rcx
lea    0xd88(%rip),%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   10d0 <read_file_of_profit@plt>
test   %rax,%rax
jle    140c <main+0x20c>
lea    0xdc5(%rip),%rdi
mov    %r12,%rsi
call   1090 <create_file_ordered_list@plt>
test   %rax,%rax
jle    141c <main+0x21c>
mov    (%rsp),%rdx
lea    0xda9(%rip),%rdi
mov    %r12,%rsi
call   1060 <read_file_ordered_list@plt>
test   %rax,%rax
jle    1425 <main+0x225>
mov    (%rsp),%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1050 <check_methods@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    (%rbx),%rsi
lea    0xc78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xeb2(%rip),%rdi
jmp    13af <main+0x1af>
lea    0xe6d(%rip),%rdi
jmp    13af <main+0x1af>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xe06(%rip),%rdi
jmp    13d4 <main+0x1d4>
lea    0xdd9(%rip),%rdi
jmp    13d4 <main+0x1d4>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xc5b(%rip),%rdi
jmp    13f3 <main+0x1f3>
lea    0xc7a(%rip),%rdi
lea    0xc3f(%rip),%rsi
jmp    1433 <main+0x233>
lea    0xc9c(%rip),%rdi
lea    0xc8a(%rip),%rsi
jmp    1433 <main+0x233>
lea    0xcb3(%rip),%rdi
lea    0xc7a(%rip),%rsi
jmp    1433 <main+0x233>
lea    0xcda(%rip),%rdi
jmp    142c <main+0x22c>
lea    0xd10(%rip),%rdi
lea    0xcb9(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"Usage: %s <max_precincts> <max_quality_layers> <budget>\0A\00"
@.str.1 = [56 x i8] c"The max number of precincts must be a positive integer\0A\00"
@.str.2 = [61 x i8] c"The max number of quality layers must be a positive integer\0A\00"
@.str.3 = [39 x i8] c"The budget must be a positive integer\0A\00"
@.str.4 = [38 x i8] c"Error allocating memory for weights.\0A\00"
@.str.5 = [37 x i8] c"Error allocating memory for profit.\0A\00"
@.str.6 = [43 x i8] c"Error allocating memory for ordered list.\0A\00"
@.str.7 = [12 x i8] c"weights.txt\00"
@.str.8 = [40 x i8] c"Error creating the file of weights: %s\0A\00"
@.str.9 = [39 x i8] c"Error reading the file of weights: %s\0A\00"
@.str.10 = [11 x i8] c"profit.txt\00"
@.str.11 = [39 x i8] c"Error creating the file of profit: %s\0A\00"
@.str.12 = [38 x i8] c"Error reading the file of profit: %s\0A\00"
@.str.13 = [17 x i8] c"ordered_list.txt\00"
@.str.14 = [63 x i8] c"Error creating the file for the ordered list of precincts: %s\0A\00"
@.str.15 = [62 x i8] c"Error reading the file for the ordered list of precincts: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64**
%10 = alloca double**
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i8* @atoi(i8* %25)
%27 = ptrtoint i8* %26 to i64
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = icmp sle i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %22
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i8* @atoi(i8* %36)
%38 = ptrtoint i8* %37 to i32
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %33
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 3
%47 = load i8*, i8** %46
%48 = call i8* @atoi(i8* %47)
%49 = ptrtoint i8* %48 to i64
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = icmp sle i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @exit(i32 0)
unreachable
55: ; preds = %44
%56 = call i32 @time(i32* null)
%57 = call i32 @srand(i32 %56)
%58 = load i64, i64* %7
%59 = load i32, i32* %8
%60 = call i64 @allocate_memory_for_weights(i64 %58, i32 %59, i64*** %9)
%61 = icmp sle i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %55
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %55
%66 = load i64, i64* %7
%67 = load i32, i32* %8
%68 = call i64 @allocate_memory_for_profit(i64 %66, i32 %67, double*** %10)
%69 = icmp sle i64 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %65
%74 = load i64, i64* %7
%75 = call i64 @allocate_memory_for_ordered_list(i64 %74, i64** %11)
%76 = icmp sle i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %73
%81 = load i64, i64* %7
%82 = load i32, i32* %8
%83 = call i64 @create_file_of_weights(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64 %81, i32 %82)
%84 = icmp sle i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %80
%89 = load i64, i64* %7
%90 = load i32, i32* %8
%91 = load i64**, i64*** %9
%92 = call i64 @read_file_of_weights(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64 %89, i32 %90, i64** %91)
%93 = icmp sle i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %88
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %88
%98 = load i64, i64* %7
%99 = load i32, i32* %8
%100 = call i64 @create_file_of_profit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 %98, i32 %99)
%101 = icmp sle i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %97
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %97
%106 = load i64, i64* %7
%107 = load i32, i32* %8
%108 = load double**, double*** %10
%109 = call i64 @read_file_of_profit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 %106, i32 %107, double** %108)
%110 = icmp sle i64 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %105
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %105
%115 = load i64, i64* %7
%116 = call i64 @create_file_ordered_list(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %115)
%117 = icmp sle i64 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %114
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %114
%122 = load i64, i64* %7
%123 = load i64*, i64** %11
%124 = call i64 @read_file_ordered_list(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %122, i64* %123)
%125 = icmp sle i64 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %121
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %121
%130 = load i64, i64* %7
%131 = load i32, i32* %8
%132 = load i64, i64* %6
%133 = load i64*, i64** %11
%134 = load i64**, i64*** %9
%135 = load double**, double*** %10
%136 = call i32 @check_methods(i64 %130, i32 %131, i64 %132, i64* %133, i64** %134, double** %135)
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"Usage: %s <max_precincts> <max_quality_layers> <budget>\0A\00"
@.str.7 = [12 x i8] c"weights.txt\00"
@.str.8 = [40 x i8] c"Error creating the file of weights: %s\0A\00"
@.str.9 = [39 x i8] c"Error reading the file of weights: %s\0A\00"
@.str.10 = [11 x i8] c"profit.txt\00"
@.str.11 = [39 x i8] c"Error creating the file of profit: %s\0A\00"
@.str.12 = [38 x i8] c"Error reading the file of profit: %s\0A\00"
@.str.13 = [17 x i8] c"ordered_list.txt\00"
@.str.14 = [63 x i8] c"Error creating the file for the ordered list of precincts: %s\0A\00"
@.str.15 = [62 x i8] c"Error reading the file for the ordered list of precincts: %s\0A\00"
@str = [42 x i8] c"Error allocating memory for ordered list.\00"
@str.16 = [36 x i8] c"Error allocating memory for profit.\00"
@str.17 = [37 x i8] c"Error allocating memory for weights.\00"
@str.18 = [38 x i8] c"The budget must be a positive integer\00"
@str.19 = [60 x i8] c"The max number of quality layers must be a positive integer\00"
@str.20 = [55 x i8] c"The max number of precincts must be a positive integer\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64**
%4 = alloca double**
%5 = alloca i64*
%6 = bitcast i64*** %3 to i8*
%7 = bitcast double*** %4 to i8*
%8 = bitcast i64** %5 to i8*
%9 = icmp slt i32 %0, 4
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i8* @atoi(i8* %16)
%18 = ptrtoint i8* %17 to i64
%19 = icmp slt i8* %17, inttoptr (i64 1 to i8*)
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.20, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %14
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i8* @atoi(i8* %25)
%27 = ptrtoint i8* %26 to i64
%28 = trunc i64 %27 to i32
%29 = icmp slt i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.19, i64 0, i64 0))
%32 = tail call i32 @exit(i32 0)
unreachable
33: ; preds = %23
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = tail call i8* @atoi(i8* %35)
%37 = icmp slt i8* %36, inttoptr (i64 1 to i8*)
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.18, i64 0, i64 0))
%40 = tail call i32 @exit(i32 0)
unreachable
41: ; preds = %33
%42 = tail call i32 @time(i32* null)
%43 = tail call i32 @srand(i32 %42)
%44 = call i64 @allocate_memory_for_weights(i64 %18, i32 %28, i64*** %3)
%45 = icmp slt i64 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.17, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %41
%50 = call i64 @allocate_memory_for_profit(i64 %18, i32 %28, double*** %4)
%51 = icmp slt i64 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.16, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %49
%56 = call i64 @allocate_memory_for_ordered_list(i64 %18, i64** %5)
%57 = icmp slt i64 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55
%62 = call i64 @create_file_of_weights(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64 %18, i32 %28)
%63 = icmp slt i64 %62, 1
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %61
%68 = load i64**, i64*** %3
%69 = call i64 @read_file_of_weights(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64 %18, i32 %28, i64** %68)
%70 = icmp slt i64 %69, 1
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %67
%75 = call i64 @create_file_of_profit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 %18, i32 %28)
%76 = icmp slt i64 %75, 1
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %74
%81 = load double**, double*** %4
%82 = call i64 @read_file_of_profit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 %18, i32 %28, double** %81)
%83 = icmp slt i64 %82, 1
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %80
%88 = call i64 @create_file_ordered_list(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %18)
%89 = icmp slt i64 %88, 1
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %87
%94 = load i64*, i64** %5
%95 = call i64 @read_file_ordered_list(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %18, i64* %94)
%96 = icmp slt i64 %95, 1
br i1 %96, label %97, label %100
97: ; preds = %93
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %93
%101 = ptrtoint i8* %36 to i64
%102 = load i64*, i64** %5
%103 = load i64**, i64*** %3
%104 = load double**, double*** %4
%105 = call i32 @check_methods(i64 %18, i32 %28, i64 %101, i64* %102, i64** %103, double** %104)
ret i32 0
}