#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *);
int /*<<< orphan*/ terror(char *);
void loadThresholds(int **low, int **up, char *thresholdFile) {
  int length, lowSimilarity, upSimilarity;
  FILE *fThreshold;
  if ((*low = (int *)calloc(1000, sizeof(int))) == NULL)
    terror("enought memory for LowThreshold array");
  if ((*up = (int *)calloc(1000, sizeof(int))) == NULL)
    terror("enought memory for UpperThreshold array");
  if ((fThreshold = fopen(thresholdFile, "rt")) == NULL)
    terror("open Low-Upper threshold file");
  if (fscanf(fThreshold, "%d\t%d\t%d\n", &length, &lowSimilarity,
             &upSimilarity) != 3) {
    terror("Error reading the threshold file. Wrong format intTABintTABint");
  }
  while (!feof(fThreshold)) {
    if (length >= 1000)
      terror("LowUp threshold out of range (maxL)");
    *low[length] = lowSimilarity;
    *up[length] = upSimilarity;
    if (fscanf(fThreshold, "%d\t%d\t%d\n", &length, &lowSimilarity,
               &upSimilarity) != 3) {
      terror("Error reading the threshold file. Wrong format intTABintTABint");
    }
  }
  fclose(fThreshold);
}


x86 assembly (clang, -O0):
<loadThresholds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x3e8,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11a0 <loadThresholds+0x40>
lea    0xe65(%rip),%rdi
call   1070 <terror@plt>
mov    $0x3e8,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11cc <loadThresholds+0x6c>
lea    0xe5f(%rip),%rdi
call   1070 <terror@plt>
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11f6 <loadThresholds+0x96>
lea    0xe60(%rip),%rdi
call   1070 <terror@plt>
mov    -0x30(%rbp),%rdi
lea    0xe6e(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1040 <fscanf@plt>
cmp    $0x3,%eax
je     1227 <loadThresholds+0xc7>
lea    0xe57(%rip),%rdi
call   1070 <terror@plt>
jmp    122c <loadThresholds+0xcc>
mov    -0x30(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    124a <loadThresholds+0xea>
jmp    12bb <loadThresholds+0x15b>
cmpl   $0x3e8,-0x1c(%rbp)
jl     1263 <loadThresholds+0x103>
lea    0xe5a(%rip),%rdi
call   1070 <terror@plt>
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rdx
mov    (%rax,%rdx,8),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rdx
mov    (%rax,%rdx,8),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
lea    0xddf(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1040 <fscanf@plt>
cmp    $0x3,%eax
je     12b6 <loadThresholds+0x156>
lea    0xdc8(%rip),%rdi
call   1070 <terror@plt>
jmp    122c <loadThresholds+0xcc>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadThresholds>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x3e8,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
jne    119a <loadThresholds+0x3a>
lea    0xe6b(%rip),%rdi
call   1070 <terror@plt>
mov    $0x3e8,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
jne    11bd <loadThresholds+0x5d>
lea    0xe6e(%rip),%rdi
call   1070 <terror@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e0 <loadThresholds+0x80>
lea    0xe76(%rip),%rdi
call   1070 <terror@plt>
lea    0xe88(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
call   1040 <fscanf@plt>
cmp    $0x3,%eax
je     120f <loadThresholds+0xaf>
lea    0xe6f(%rip),%rdi
call   1070 <terror@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     1232 <loadThresholds+0xd2>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc(%rsp),%rbp
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    125c <loadThresholds+0xfc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    121b <loadThresholds+0xbb>
mov    0xc(%rsp),%eax
cmp    $0x3e8,%eax
jl     1277 <loadThresholds+0x117>
lea    0xe4a(%rip),%rdi
call   1070 <terror@plt>
mov    0xc(%rsp),%eax
mov    0x14(%rsp),%ecx
cltq
mov    (%r15,%rax,8),%rax
mov    %ecx,(%rax)
mov    0x10(%rsp),%eax
movslq 0xc(%rsp),%rcx
mov    (%r14,%rcx,8),%rcx
mov    %eax,(%rcx)
mov    %rbx,%rdi
lea    0xdd3(%rip),%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1040 <fscanf@plt>
cmp    $0x3,%eax
je     1250 <loadThresholds+0xf0>
lea    0xdc3(%rip),%rdi
call   1070 <terror@plt>
jmp    1250 <loadThresholds+0xf0>

LLVM IR (-O0):
@.str = [38 x i8] c"enought memory for LowThreshold array\00"
@.str.1 = [40 x i8] c"enought memory for UpperThreshold array\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [30 x i8] c"open Low-Upper threshold file\00"
@.str.4 = [10 x i8] c"%d\09%d\09%d\0A\00"
@.str.5 = [63 x i8] c"Error reading the threshold file. Wrong format intTABintTABint\00"
@.str.6 = [36 x i8] c"LowUp threshold out of range (maxL)\00"
define void @loadThresholds(i32** %0, i32** %1, i8* %2) {
%4 = alloca i32**
%5 = alloca i32**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32** %0, i32*** %4
store i32** %1, i32*** %5
store i8* %2, i8** %6
%11 = call i64 @calloc(i32 1000, i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = load i32**, i32*** %4
store i32* %12, i32** %13
%14 = icmp eq i32* %12, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @terror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = call i64 @calloc(i32 1000, i32 4)
%19 = inttoptr i64 %18 to i32*
%20 = load i32**, i32*** %5
store i32* %19, i32** %20
%21 = icmp eq i32* %19, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @terror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %17
%25 = load i8*, i8** %6
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %10
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = load i32*, i32** %10
%32 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%33 = icmp ne i32 %32, 3
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @terror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
br label %37
37: ; preds = %65, %36
%38 = load i32*, i32** %10
%39 = call i32 @feof(i32* %38)
%40 = icmp ne i32 %39, 0
%41 = xor i1 %40, true
br i1 %41, label %42, label %66
42: ; preds = %37
%43 = load i32, i32* %7
%44 = icmp sge i32 %43, 1000
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @terror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
%48 = load i32, i32* %8
%49 = load i32**, i32*** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32*, i32** %49, i64 %51
%53 = load i32*, i32** %52
store i32 %48, i32* %53
%54 = load i32, i32* %9
%55 = load i32**, i32*** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32*, i32** %55, i64 %57
%59 = load i32*, i32** %58
store i32 %54, i32* %59
%60 = load i32*, i32** %10
%61 = call i32 @fscanf(i32* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%62 = icmp ne i32 %61, 3
br i1 %62, label %63, label %65
63: ; preds = %47
%64 = call i32 @terror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %63, %47
br label %37
66: ; preds = %37
%67 = load i32*, i32** %10
%68 = call i32 @fclose(i32* %67)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"enought memory for LowThreshold array\00"
@.str.1 = [40 x i8] c"enought memory for UpperThreshold array\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [30 x i8] c"open Low-Upper threshold file\00"
@.str.4 = [10 x i8] c"%d\09%d\09%d\0A\00"
@.str.5 = [63 x i8] c"Error reading the threshold file. Wrong format intTABintTABint\00"
@.str.6 = [36 x i8] c"LowUp threshold out of range (maxL)\00"
define void @loadThresholds(i32** nocapture %0, i32** nocapture %1, i8* nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = tail call i64 @calloc(i32 1000, i32 4)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %0
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = tail call i32 @terror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %3
%16 = tail call i64 @calloc(i32 1000, i32 4)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %1
%18 = icmp eq i64 %16, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @terror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%28 = icmp eq i32 %27, 3
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 @terror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = call i32 @feof(i32* %22)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %58
34: ; preds = %31, %55
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 999
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = call i32 @terror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%39 = load i32, i32* %4
br label %40
40: ; preds = %37, %34
%41 = phi i32 [ %39, %37 ], [ %35, %34 ]
%42 = load i32, i32* %5
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i32*, i32** %0, i64 %43
%45 = load i32*, i32** %44
store i32 %42, i32* %45
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32*, i32** %1, i64 %48
%50 = load i32*, i32** %49
store i32 %46, i32* %50
%51 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%52 = icmp eq i32 %51, 3
br i1 %52, label %55, label %53
53: ; preds = %40
%54 = call i32 @terror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %40
%56 = call i32 @feof(i32* %22)
%57 = icmp eq i32 %56, 0
br i1 %57, label %34, label %58
58: ; preds = %55, %31
%59 = call i32 @fclose(i32* %22)
ret void
}