#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *strchr(char *, char);
int getSize(FILE *file) {
  int size;
  int line = 0;
  char buffer[800 + 1];
  char *location;
  while (line < 1) {
    if (fgets(buffer, 800, file) == NULL) {
      printf("Size could not be gathered.  File not long enough.\n");
      exit(-1);
    }
    location = strchr(buffer, '\n');
    if (!location) {
      printf("Size could not be gathered.  Line %d too large for buffer.\n",
             line);
      exit(0);
    }
    *location = '\0';
    location = strchr(buffer, '#');
    if (!location) {
      size = atoi(buffer);
      line++;
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<getSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1232 <getSize+0xe2>
lea    -0x340(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x320,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11a7 <getSize+0x57>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
lea    -0x340(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x348(%rbp)
cmpq   $0x0,-0x348(%rbp)
jne    11e5 <getSize+0x95>
mov    -0x10(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x348(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x340(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
mov    %rax,-0x348(%rbp)
cmpq   $0x0,-0x348(%rbp)
jne    122d <getSize+0xdd>
lea    -0x340(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <getSize+0x16>
mov    -0xc(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSize>:
push   %r14
push   %rbx
sub    $0x328,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x320,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11bf <getSize+0x5f>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11d5 <getSize+0x75>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1170 <getSize+0x10>
mov    %rsp,%rdi
call   1070 <atoi@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xe24(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"Size could not be gathered. File not long enough.\0A\00"
@.str.1 = [60 x i8] c"Size could not be gathered. Line %d too large for buffer.\0A\00"
define i32 @getSize(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [801 x i8]
%6 = alloca i8*
store i32* %0, i32** %2
store i32 0, i32* %4
br label %7
7: ; preds = %38, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %39
10: ; preds = %7
%11 = getelementptr inbounds [801 x i8], [801 x i8]* %5, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32* @fgets(i8* %11, i32 800, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %10
%19 = getelementptr inbounds [801 x i8], [801 x i8]* %5, i64 0, i64 0
%20 = call i8* @strchr(i8* %19, i8 signext 10)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %18
%28 = load i8*, i8** %6
store i8 0, i8* %28
%29 = getelementptr inbounds [801 x i8], [801 x i8]* %5, i64 0, i64 0
%30 = call i8* @strchr(i8* %29, i8 signext 35)
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = icmp ne i8* %31, null
br i1 %32, label %38, label %33
33: ; preds = %27
%34 = getelementptr inbounds [801 x i8], [801 x i8]* %5, i64 0, i64 0
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %3
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %38
38: ; preds = %33, %27
br label %7
39: ; preds = %7
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [60 x i8] c"Size could not be gathered. Line %d too large for buffer.\0A\00"
@str = [51 x i8] c"Size could not be gathered. File not long enough.\00"
define i32 @getSize(i32* nocapture %0) {
%2 = alloca [801 x i8]
%3 = getelementptr inbounds [801 x i8], [801 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %16, %1
%5 = call i32* @fgets(i8* %3, i32 800, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %4
%11 = call i8* @strchr(i8* %3, i8 signext 10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 0)
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %10
store i8 0, i8* %11
%17 = call i8* @strchr(i8* %3, i8 signext 35)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %4
19: ; preds = %16
%20 = call i32 @atoi(i8* %3)
ret i32 %20
}