#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
long strtol(char *, char **, int);
int /*<<< orphan*/ ungetc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  char line[16 + 1];
  char *next;
  FILE *inFile;
  long sides[3][3];
  int s, t;
  int numTriangles = 0;
  if (argc != 2) {
    fprintf(stderr, "Usage:\n\tDay3 <input filename>\n\n");
    return EXIT_FAILURE;
  }
  inFile = fopen(argv[1], "r");
  if (inFile == NULL) {
    fprintf(stderr, "Error opening file: %s\n\n", strerror(errno));
    return EXIT_FAILURE;
  }
  while (!feof(inFile)) {
    for (s = 0; s < 3; s++) {
      fgets(line, 16 + 1, inFile);
      next = line;
      for (t = 0; t < 3; t++) {
        sides[t][s] = strtol(next, &next, 10);
        if (sides[t][s] == 0) {
          fprintf(stderr, "Error parsing numbers: %s\n\n", strerror(errno));
          fprintf(stderr, "Line: %s\n", line);
          fclose(inFile);
          return EXIT_FAILURE;
        }
      }
    }
    for (t = 0; t < 3; t++) {
      if (sides[t][0] + sides[t][1] > sides[t][2] &&
          sides[t][1] + sides[t][2] > sides[t][0] &&
          sides[t][2] + sides[t][0] > sides[t][1]) {
        numTriangles++;
      }
    }
    ungetc(fgetc(inFile), inFile);
  }
  fclose(inFile);
  printf("Number of possible triangles: %d\n", numTriangles);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x9c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f5 <main+0x55>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    152e <main+0x38e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    125d <main+0xbd>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xa0(%rbp),%edi
mov    %rax,%rdx
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    152e <main+0x38e>
jmp    1262 <main+0xc2>
mov    -0x40(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1280 <main+0xe0>
jmp    1507 <main+0x367>
movl   $0x0,-0x94(%rbp)
cmpl   $0x3,-0x94(%rbp)
jge    13bf <main+0x21f>
lea    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    $0x11,%esi
call   1060 <fgets@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x98(%rbp)
cmpl   $0x3,-0x98(%rbp)
jge    13a6 <main+0x206>
mov    -0x38(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%rdx
movslq -0x98(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x94(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x98(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x94(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    138d <main+0x1ed>
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xa4(%rbp),%edi
mov    %rax,%rdx
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    152e <main+0x38e>
jmp    1392 <main+0x1f2>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    12bb <main+0x11b>
jmp    13ab <main+0x20b>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    128a <main+0xea>
movl   $0x0,-0x98(%rbp)
cmpl   $0x3,-0x98(%rbp)
jge    14ee <main+0x34e>
movslq -0x98(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
add    0x8(%rcx),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    0x10(%rcx),%rax
jle    14d5 <main+0x335>
movslq -0x98(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
add    0x10(%rcx),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    (%rcx),%rax
jle    14d5 <main+0x335>
movslq -0x98(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
add    (%rcx),%rax
movslq -0x98(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
cmp    0x8(%rcx),%rax
jle    14d5 <main+0x335>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    14da <main+0x33a>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    13c9 <main+0x229>
mov    -0x40(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,%edi
mov    -0x40(%rbp),%rsi
call   10a0 <ungetc@plt>
jmp    1262 <main+0xc2>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x9c(%rbp),%esi
lea    0xb44(%rip),%rdi
call   1040 <printf@plt>
mov    0x2a9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jne    11fd <main+0x5d>
mov    0x8(%rsi),%rdi
lea    0xe62(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1219 <main+0x79>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1248 <main+0xa8>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe78(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    0x2dd0(%rip),%rax
jmp    14b1 <main+0x311>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    14aa <main+0x30a>
mov    0x2dc0(%rip),%rax
mov    (%rax),%ebx
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xdeb(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    14aa <main+0x30a>
xor    %r14d,%r14d
mov    %rsp,%r12
mov    %rbx,0x8(%rsp)
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x11,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbp,(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     145f <main+0x2bf>
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     145f <main+0x2bf>
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     145f <main+0x2bf>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x11,%esi
mov    0x8(%rsp),%rdx
call   1060 <fgets@plt>
mov    %rbx,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
test   %rax,%rax
je     145f <main+0x2bf>
mov    %rax,%r13
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
test   %rax,%rax
je     145f <main+0x2bf>
mov    %rax,%rbp
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     145f <main+0x2bf>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x11,%esi
mov    0x8(%rsp),%rdx
call   1060 <fgets@plt>
mov    %rbx,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
test   %rax,%rax
je     145f <main+0x2bf>
mov    %rax,%r15
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
test   %rax,%rax
je     145f <main+0x2bf>
mov    %rax,%rbx
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
test   %rax,%rax
je     145f <main+0x2bf>
mov    0x28(%rsp),%rsi
lea    (%rsi,%r13,1),%rcx
cmp    %r15,%rcx
setg   %cl
lea    (%r15,%r13,1),%rdx
cmp    %rsi,%rdx
setg   %dl
and    %cl,%dl
add    %rsi,%r15
cmp    %r13,%r15
setg   %cl
and    %dl,%cl
movzbl %cl,%ecx
add    %ecx,%r14d
mov    0x20(%rsp),%rsi
lea    (%rsi,%rbp,1),%rcx
cmp    %rbx,%rcx
setg   %cl
lea    (%rbx,%rbp,1),%rdx
cmp    %rsi,%rdx
setg   %dl
and    %cl,%dl
add    %rsi,%rbx
cmp    %rbp,%rbx
setg   %cl
and    %dl,%cl
movzbl %cl,%ecx
add    %r14d,%ecx
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rbp
lea    (%rdi,%rbp,1),%rdx
cmp    %rax,%rdx
setg   %dl
lea    (%rax,%rbp,1),%rsi
cmp    %rdi,%rsi
setg   %bl
and    %dl,%bl
add    %rdi,%rax
cmp    %rbp,%rax
setg   %al
and    %bl,%al
movzbl %al,%r14d
add    %ecx,%r14d
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <ungetc@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1253 <main+0xb3>
jmp    11da <main+0x3a>
mov    0x2b7a(%rip),%rbp
mov    0x0(%rbp),%ebx
mov    0x2b68(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xbbd(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xbc3(%rip),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    0x2b1f(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Usage:\0A\09Day3 <input filename>\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Error opening file: %s\0A\0A\00"
@errno = global i32 0
@.str.3 = [28 x i8] c"Error parsing numbers: %s\0A\0A\00"
@.str.4 = [10 x i8] c"Line: %s\0A\00"
@.str.5 = [34 x i8] c"Number of possible triangles: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [17 x i8]
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca [3 x [3 x i64]]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %162
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %8
%24 = load i32*, i32** %8
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %162
32: ; preds = %19
br label %33
33: ; preds = %151, %32
%34 = load i32*, i32** %8
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %156
38: ; preds = %33
store i32 0, i32* %10
br label %39
39: ; preds = %83, %38
%40 = load i32, i32* %10
%41 = icmp slt i32 %40, 3
br i1 %41, label %42, label %86
42: ; preds = %39
%43 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%44 = load i32*, i32** %8
%45 = call i32 @fgets(i8* %43, i32 17, i32* %44)
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
store i8* %46, i8** %7
store i32 0, i32* %11
br label %47
47: ; preds = %79, %42
%48 = load i32, i32* %11
%49 = icmp slt i32 %48, 3
br i1 %49, label %50, label %82
50: ; preds = %47
%51 = load i8*, i8** %7
%52 = call i64 @strtol(i8* %51, i8** %7, i32 10)
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %54
%56 = load i32, i32* %10
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x i64], [3 x i64]* %55, i64 0, i64 %57
store i64 %52, i64* %58
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %60
%62 = load i32, i32* %10
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [3 x i64], [3 x i64]* %61, i64 0, i64 %63
%65 = load i64, i64* %64
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %78
67: ; preds = %50
%68 = load i32, i32* @stderr
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @stderr
%73 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = load i32*, i32** %8
%76 = call i32 @fclose(i32* %75)
%77 = load i32, i32* @EXIT_FAILURE
store i32 %77, i32* %3
br label %162
78: ; preds = %50
br label %79
79: ; preds = %78
%80 = load i32, i32* %11
%81 = add nsw i32 %80, 1
store i32 %81, i32* %11
br label %47
82: ; preds = %47
br label %83
83: ; preds = %82
%84 = load i32, i32* %10
%85 = add nsw i32 %84, 1
store i32 %85, i32* %10
br label %39
86: ; preds = %39
store i32 0, i32* %11
br label %87
87: ; preds = %148, %86
%88 = load i32, i32* %11
%89 = icmp slt i32 %88, 3
br i1 %89, label %90, label %151
90: ; preds = %87
%91 = load i32, i32* %11
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %92
%94 = getelementptr inbounds [3 x i64], [3 x i64]* %93, i64 0, i64 0
%95 = load i64, i64* %94
%96 = load i32, i32* %11
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %97
%99 = getelementptr inbounds [3 x i64], [3 x i64]* %98, i64 0, i64 1
%100 = load i64, i64* %99
%101 = add nsw i64 %95, %100
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %103
%105 = getelementptr inbounds [3 x i64], [3 x i64]* %104, i64 0, i64 2
%106 = load i64, i64* %105
%107 = icmp sgt i64 %101, %106
br i1 %107, label %108, label %147
108: ; preds = %90
%109 = load i32, i32* %11
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %110
%112 = getelementptr inbounds [3 x i64], [3 x i64]* %111, i64 0, i64 1
%113 = load i64, i64* %112
%114 = load i32, i32* %11
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %115
%117 = getelementptr inbounds [3 x i64], [3 x i64]* %116, i64 0, i64 2
%118 = load i64, i64* %117
%119 = add nsw i64 %113, %118
%120 = load i32, i32* %11
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %121
%123 = getelementptr inbounds [3 x i64], [3 x i64]* %122, i64 0, i64 0
%124 = load i64, i64* %123
%125 = icmp sgt i64 %119, %124
br i1 %125, label %126, label %147
126: ; preds = %108
%127 = load i32, i32* %11
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %128
%130 = getelementptr inbounds [3 x i64], [3 x i64]* %129, i64 0, i64 2
%131 = load i64, i64* %130
%132 = load i32, i32* %11
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %133
%135 = getelementptr inbounds [3 x i64], [3 x i64]* %134, i64 0, i64 0
%136 = load i64, i64* %135
%137 = add nsw i64 %131, %136
%138 = load i32, i32* %11
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 %139
%141 = getelementptr inbounds [3 x i64], [3 x i64]* %140, i64 0, i64 1
%142 = load i64, i64* %141
%143 = icmp sgt i64 %137, %142
br i1 %143, label %144, label %147
144: ; preds = %126
%145 = load i32, i32* %12
%146 = add nsw i32 %145, 1
store i32 %146, i32* %12
br label %147
147: ; preds = %144, %126, %108, %90
br label %148
148: ; preds = %147
%149 = load i32, i32* %11
%150 = add nsw i32 %149, 1
store i32 %150, i32* %11
br label %87
151: ; preds = %87
%152 = load i32*, i32** %8
%153 = call i32 @fgetc(i32* %152)
%154 = load i32*, i32** %8
%155 = call i32 @ungetc(i32 %153, i32* %154)
br label %33
156: ; preds = %33
%157 = load i32*, i32** %8
%158 = call i32 @fclose(i32* %157)
%159 = load i32, i32* %12
%160 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %159)
%161 = load i32, i32* @EXIT_SUCCESS
store i32 %161, i32* %3
br label %162
162: ; preds = %156, %67, %26, %15
%163 = load i32, i32* %3
ret i32 %163
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Usage:\0A\09Day3 <input filename>\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Error opening file: %s\0A\0A\00"
@errno = global i32 0
@.str.3 = [28 x i8] c"Error parsing numbers: %s\0A\0A\00"
@.str.4 = [10 x i8] c"Line: %s\0A\00"
@.str.5 = [34 x i8] c"Number of possible triangles: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [17 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %108
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 @feof(i32* %14)
%18 = icmp eq i32 %17, 0
br i1 %18, label %24, label %104
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %108
24: ; preds = %16, %61
%25 = phi i32 [ %91, %61 ], [ 0, %16 ]
%26 = call i32 @fgets(i8* %5, i32 17, i32* %14)
store i8* %5, i8** %4
%27 = call i64 @strtol(i8* %5, i8** %4, i32 10)
%28 = icmp eq i64 %27, 0
br i1 %28, label %96, label %29
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = call i64 @strtol(i8* %30, i8** %4, i32 10)
%32 = icmp eq i64 %31, 0
br i1 %32, label %96, label %33
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = call i64 @strtol(i8* %34, i8** %4, i32 10)
%36 = icmp eq i64 %35, 0
br i1 %36, label %96, label %37
37: ; preds = %33
%38 = call i32 @fgets(i8* %5, i32 17, i32* %14)
store i8* %5, i8** %4
%39 = call i64 @strtol(i8* %5, i8** %4, i32 10)
%40 = icmp eq i64 %39, 0
br i1 %40, label %96, label %41
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = call i64 @strtol(i8* %42, i8** %4, i32 10)
%44 = icmp eq i64 %43, 0
br i1 %44, label %96, label %45
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = call i64 @strtol(i8* %46, i8** %4, i32 10)
%48 = icmp eq i64 %47, 0
br i1 %48, label %96, label %49
49: ; preds = %45
%50 = call i32 @fgets(i8* %5, i32 17, i32* %14)
store i8* %5, i8** %4
%51 = call i64 @strtol(i8* %5, i8** %4, i32 10)
%52 = icmp eq i64 %51, 0
br i1 %52, label %96, label %53
53: ; preds = %49
%54 = load i8*, i8** %4
%55 = call i64 @strtol(i8* %54, i8** %4, i32 10)
%56 = icmp eq i64 %55, 0
br i1 %56, label %96, label %57
57: ; preds = %53
%58 = load i8*, i8** %4
%59 = call i64 @strtol(i8* %58, i8** %4, i32 10)
%60 = icmp eq i64 %59, 0
br i1 %60, label %96, label %61
61: ; preds = %57
%62 = add nsw i64 %39, %27
%63 = icmp sgt i64 %62, %51
%64 = add nsw i64 %51, %39
%65 = icmp sgt i64 %64, %27
%66 = select i1 %63, i1 %65, i1 false
%67 = add nsw i64 %51, %27
%68 = icmp sgt i64 %67, %39
%69 = select i1 %66, i1 %68, i1 false
%70 = zext i1 %69 to i32
%71 = add nsw i32 %25, %70
%72 = add nsw i64 %43, %31
%73 = icmp sgt i64 %72, %55
%74 = add nsw i64 %55, %43
%75 = icmp sgt i64 %74, %31
%76 = select i1 %73, i1 %75, i1 false
%77 = add nsw i64 %55, %31
%78 = icmp sgt i64 %77, %43
%79 = select i1 %76, i1 %78, i1 false
%80 = zext i1 %79 to i32
%81 = add nsw i32 %71, %80
%82 = add nsw i64 %47, %35
%83 = icmp sgt i64 %82, %59
%84 = add nsw i64 %59, %47
%85 = icmp sgt i64 %84, %35
%86 = select i1 %83, i1 %85, i1 false
%87 = add nsw i64 %59, %35
%88 = icmp sgt i64 %87, %47
%89 = select i1 %86, i1 %88, i1 false
%90 = zext i1 %89 to i32
%91 = add nsw i32 %81, %90
%92 = call i32 @fgetc(i32* %14)
%93 = call i32 @ungetc(i32 %92, i32* %14)
%94 = call i32 @feof(i32* %14)
%95 = icmp eq i32 %94, 0
br i1 %95, label %24, label %104
96: ; preds = %57, %53, %49, %45, %41, %37, %33, %29, %24
%97 = load i32, i32* @stderr
%98 = load i32, i32* @errno
%99 = call i8* @strerror(i32 %98)
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %99)
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%103 = call i32 @fclose(i32* %14)
br label %108
104: ; preds = %61, %16
%105 = phi i32 [ 0, %16 ], [ %91, %61 ]
%106 = call i32 @fclose(i32* %14)
%107 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %105)
br label %108
108: ; preds = %104, %96, %19, %8
%109 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_FAILURE, %19 ], [ @EXIT_FAILURE, %96 ], [ @EXIT_SUCCESS, %104 ]
%110 = load i32, i32* %109
ret i32 %110
}