#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ stderr;
void getFileInfo(char *filename, int *numContigs, int *seqLen, int *numHits) {
  FILE *file;
  int dummy, i;
  if (!(file = fopen(filename, "r"))) {
    fprintf(stderr, "contigorder: Error opening file: %s\n");
    exit(1);
  }
  fscanf(file, "numContigs = %d\n", numContigs);
  fscanf(file, "seqLen = %d\n", seqLen);
  *numHits = 0;
  while (!feof(file)) {
    if (fscanf(file, "(%d %d)", &dummy, &dummy) == 2) {
      for (i = 0; i < *numContigs; i++) {
        fscanf(file, "%&d", &dummy);
      }
      while (fgetc(file) != '\n')
        ;
      (*numHits)++;
    }
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<getFileInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11c5 <getFileInfo+0x55>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1219 <getFileInfo+0xa9>
jmp    12a4 <getFileInfo+0x134>
mov    -0x28(%rbp),%rdi
lea    0xe21(%rip),%rsi
lea    -0x2c(%rbp),%rcx
mov    %rcx,%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    129f <getFileInfo+0x12f>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1275 <getFileInfo+0x105>
mov    -0x28(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1242 <getFileInfo+0xd2>
jmp    127a <getFileInfo+0x10a>
mov    -0x28(%rbp),%rdi
call   1050 <fgetc@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1294 <getFileInfo+0x124>
jmp    127a <getFileInfo+0x10a>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11fb <getFileInfo+0x8b>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r15
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     127d <getFileInfo+0x10d>
mov    %rax,%rbx
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
movl   $0x0,(%r14)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11ee <getFileInfo+0x7e>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe50(%rip),%r12
lea    0x4(%rsp),%r13
lea    0xe4c(%rip),%rbp
jmp    121c <getFileInfo+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11d7 <getFileInfo+0x67>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    1210 <getFileInfo+0xa0>
mov    %r14,%r12
cmpl   $0x0,(%r15)
jle    1260 <getFileInfo+0xf0>
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x1,%r14d
cmp    (%r15),%r14d
jl     1240 <getFileInfo+0xd0>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%al
jne    1260 <getFileInfo+0xf0>
mov    %r12,%r14
addl   $0x1,(%r12)
lea    0xdca(%rip),%r12
jmp    1210 <getFileInfo+0xa0>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xd75(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"contigorder: Error opening file: %s\0A\00"
@.str.2 = [17 x i8] c"numContigs = %d\0A\00"
@.str.3 = [13 x i8] c"seqLen = %d\0A\00"
@.str.4 = [8 x i8] c"(%d %d)\00"
@.str.5 = [4 x i8] c"%&d\00"
define void @getFileInfo(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
%14 = icmp ne i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %4
%20 = load i32*, i32** %9
%21 = load i32*, i32** %6
%22 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32* %21)
%23 = load i32*, i32** %9
%24 = load i32*, i32** %7
%25 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32* %24)
%26 = load i32*, i32** %8
store i32 0, i32* %26
br label %27
27: ; preds = %59, %19
%28 = load i32*, i32** %9
%29 = call i32 @feof(i32* %28)
%30 = icmp ne i32 %29, 0
%31 = xor i1 %30, true
br i1 %31, label %32, label %60
32: ; preds = %27
%33 = load i32*, i32** %9
%34 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %10)
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %59
36: ; preds = %32
store i32 0, i32* %11
br label %37
37: ; preds = %45, %36
%38 = load i32, i32* %11
%39 = load i32*, i32** %6
%40 = load i32, i32* %39
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = load i32*, i32** %9
%44 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %10)
br label %45
45: ; preds = %42
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %37
48: ; preds = %37
br label %49
49: ; preds = %54, %48
%50 = load i32*, i32** %9
%51 = call signext i8 @fgetc(i32* %50)
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 10
br i1 %53, label %54, label %55
54: ; preds = %49
br label %49
55: ; preds = %49
%56 = load i32*, i32** %8
%57 = load i32, i32* %56
%58 = add nsw i32 %57, 1
store i32 %58, i32* %56
br label %59
59: ; preds = %55, %32
br label %27
60: ; preds = %27
%61 = load i32*, i32** %9
%62 = call i32 @fclose(i32* %61)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"contigorder: Error opening file: %s\0A\00"
@.str.2 = [17 x i8] c"numContigs = %d\0A\00"
@.str.3 = [13 x i8] c"seqLen = %d\0A\00"
@.str.4 = [8 x i8] c"(%d %d)\00"
@.str.5 = [4 x i8] c"%&d\00"
define void @getFileInfo(i8* nocapture %0, i32* %1, i32* %2, i32* nocapture %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %4
%14 = tail call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = tail call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
%16 = call i32 @feof(i32* %7)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %40
18: ; preds = %13, %37
%19 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %5)
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %37
21: ; preds = %18
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21, %24
%25 = phi i32 [ %27, %24 ], [ 0, %21 ]
%26 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%27 = add nuw nsw i32 %25, 1
%28 = load i32, i32* %1
%29 = icmp slt i32 %27, %28
br i1 %29, label %24, label %30
30: ; preds = %24, %21
br label %31
31: ; preds = %30, %31
%32 = call signext i8 @fgetc(i32* %7)
%33 = icmp eq i8 %32, 10
br i1 %33, label %34, label %31
34: ; preds = %31
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %37
37: ; preds = %34, %18
%38 = call i32 @feof(i32* %7)
%39 = icmp eq i32 %38, 0
br i1 %39, label %18, label %40
40: ; preds = %37, %13
%41 = call i32 @fclose(i32* %7)
ret void
}