#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 */
int abs(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int *malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int *loadEquation(char *filename, int *numBools, int *numClauses) {
  *numBools = 0;
  *numClauses = 0;
  FILE *file = fopen(filename, "r");
  int ind = 0, qb = 0;
  do {
    fscanf(file, "%d", &qb);
    if (abs(qb) > *numBools)
      *numBools = abs(qb);
    if (++ind == 3)
      *numClauses += 1;
    ind %= 3;
  } while (!feof(file));
  rewind(file);
  int *equ = malloc(*numClauses * 3 * sizeof(int));
  for (ind = 0; ind < *numClauses * 3; ind++)
    fscanf(file, "%d", &equ[ind]);
  fclose(file);
  return equ;
}


x86 assembly (clang, -O0):
<loadEquation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe3d(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x28(%rbp),%edi
call   1030 <abs@plt>
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    11f2 <loadEquation+0x82>
mov    -0x28(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x3,%eax
jne    120f <loadEquation+0x9f>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ba <loadEquation+0x4a>
mov    -0x20(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x18(%rbp),%rax
imul   $0x3,(%rax),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
imul   $0x3,(%rcx),%ecx
cmp    %ecx,%eax
jge    129d <loadEquation+0x12d>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd78(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    125e <loadEquation+0xee>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadEquation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r13
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
lea    0xe65(%rip),%r12
lea    0x4(%rsp),%rbp
jmp    11d8 <loadEquation+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
mov    %r13,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1207 <loadEquation+0xa7>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1050 <fscanf@plt>
mov    0x4(%rsp),%ecx
mov    %ecx,%eax
neg    %eax
cmovs  %ecx,%eax
cmp    (%r15),%eax
jle    11f9 <loadEquation+0x99>
mov    %eax,(%r15)
add    $0x1,%ebx
cmp    $0x3,%ebx
jne    11b0 <loadEquation+0x50>
addl   $0x1,(%r14)
jmp    11b0 <loadEquation+0x50>
mov    %r13,%rdi
call   1040 <rewind@plt>
mov    (%r14),%ebx
lea    0x0(,%rbx,4),%eax
lea    (%rax,%rax,2),%edi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %ebx,%ebx
jle    1262 <loadEquation+0x102>
xor    %ebp,%ebp
lea    0xdd1(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
add    $0x1,%rbp
movslq (%r14),%rax
lea    (%rax,%rax,2),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1240 <loadEquation+0xe0>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
define i32* @loadEquation(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%11 = load i32*, i32** %5
store i32 0, i32* %11
%12 = load i32*, i32** %6
store i32 0, i32* %12
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %38, %3
%16 = load i32*, i32** %7
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%18 = load i32, i32* %9
%19 = call i32 @abs(i32 %18)
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = icmp sgt i32 %19, %21
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* %9
%25 = call i32 @abs(i32 %24)
%26 = load i32*, i32** %5
store i32 %25, i32* %26
br label %27
27: ; preds = %23, %15
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32*, i32** %6
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
br label %35
35: ; preds = %31, %27
%36 = load i32, i32* %8
%37 = srem i32 %36, 3
store i32 %37, i32* %8
br label %38
38: ; preds = %35
%39 = load i32*, i32** %7
%40 = call i32 @feof(i32* %39)
%41 = icmp ne i32 %40, 0
%42 = xor i1 %41, true
br i1 %42, label %15, label %43
43: ; preds = %38
%44 = load i32*, i32** %7
%45 = call i32 @rewind(i32* %44)
%46 = load i32*, i32** %6
%47 = load i32, i32* %46
%48 = mul nsw i32 %47, 3
%49 = sext i32 %48 to i64
%50 = mul i64 %49, 4
%51 = trunc i64 %50 to i32
%52 = call i32* @malloc(i32 %51)
store i32* %52, i32** %10
store i32 0, i32* %8
br label %53
53: ; preds = %66, %43
%54 = load i32, i32* %8
%55 = load i32*, i32** %6
%56 = load i32, i32* %55
%57 = mul nsw i32 %56, 3
%58 = icmp slt i32 %54, %57
br i1 %58, label %59, label %69
59: ; preds = %53
%60 = load i32*, i32** %7
%61 = load i32*, i32** %10
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = call i32 @fscanf(i32* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %64)
br label %66
66: ; preds = %59
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %53
69: ; preds = %53
%70 = load i32*, i32** %7
%71 = call i32 @fclose(i32* %70)
%72 = load i32*, i32** %10
ret i32* %72
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
define i32* @loadEquation(i8* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %21, %3
%8 = phi i32 [ 0, %3 ], [ %22, %21 ]
%9 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = call i32 @llvm.abs.i32(i32 %10, i1 true)
%12 = load i32, i32* %1
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 %11, i32* %1
br label %15
15: ; preds = %14, %7
%16 = add nsw i32 %8, 1
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %21
21: ; preds = %18, %15
%22 = srem i32 %16, 3
%23 = call i32 @feof(i32* %5)
%24 = icmp eq i32 %23, 0
br i1 %24, label %7, label %25
25: ; preds = %21
%26 = call i32 @rewind(i32* %5)
%27 = load i32, i32* %2
%28 = mul i32 %27, 12
%29 = call i32* @malloc(i32 %28)
%30 = icmp sgt i32 %27, 0
br i1 %30, label %31, label %40
31: ; preds = %25, %31
%32 = phi i64 [ %35, %31 ], [ 0, %25 ]
%33 = getelementptr inbounds i32, i32* %29, i64 %32
%34 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
%35 = add nuw nsw i64 %32, 1
%36 = load i32, i32* %2
%37 = mul nsw i32 %36, 3
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %35, %38
br i1 %39, label %31, label %40
40: ; preds = %31, %25
%41 = call i32 @fclose(i32* %5)
ret i32* %29
}