#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_file_info(unsigned char *, unsigned char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(unsigned char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isspace(unsigned char);
int sscanf(unsigned char *, char *, unsigned char *, int *);
int /*<<< orphan*/ stderr;
int strlen(unsigned char *);
int read_file_info(const unsigned char *name) {
  FILE *f = fopen(name, "r");
  if (!f)
    return -1;
  unsigned char buf[1024];
  while (fgets(buf, sizeof(buf), f)) {
    int buflen = strlen(buf);
    if (buflen == sizeof(buf) - 1 && buf[buflen - 1] != '\n') {
      fprintf(stderr, "input line is too long\n");
      exit(1);
    }
    while (buflen > 0 && isspace(buf[buflen - 1]))
      --buflen;
    buf[buflen] = 0;
    if (buflen <= 0)
      continue;
    unsigned char summ[sizeof(buf)];
    int n = 0;
    if (sscanf(buf, "%s%n", summ, &n) != 1) {
      fprintf(stderr, "invalid input file\n");
      exit(1);
    }
    while (isspace(buf[n]))
      ++n;
    add_file_info(summ, buf + n);
  }
  fclose(f);
  f = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<read_file_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ca <read_file_info+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1399 <read_file_info+0x209>
jmp    11cf <read_file_info+0x3f>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1381 <read_file_info+0x1f1>
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x424(%rbp)
movslq -0x424(%rbp),%rax
cmp    $0x3ff,%rax
jne    124e <read_file_info+0xbe>
mov    -0x424(%rbp),%eax
sub    $0x1,%eax
cltq
movzbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     124e <read_file_info+0xbe>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1253 <read_file_info+0xc3>
xor    %eax,%eax
cmpl   $0x0,-0x424(%rbp)
mov    %al,-0x835(%rbp)
jle    128d <read_file_info+0xfd>
mov    -0x424(%rbp),%eax
sub    $0x1,%eax
cltq
movzbl -0x420(%rbp,%rax,1),%edi
ff
call   1050 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x835(%rbp)
mov    -0x835(%rbp),%al
test   $0x1,%al
jne    12a0 <read_file_info+0x110>
jmp    12b4 <read_file_info+0x124>
mov    -0x424(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x424(%rbp)
jmp    1253 <read_file_info+0xc3>
movslq -0x424(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
cmpl   $0x0,-0x424(%rbp)
jg     12d5 <read_file_info+0x145>
jmp    11cf <read_file_info+0x3f>
movl   $0x0,-0x834(%rbp)
lea    -0x420(%rbp),%rdi
lea    -0x830(%rbp),%rdx
lea    0xd26(%rip),%rsi
lea    -0x834(%rbp),%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
je     1328 <read_file_info+0x198>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    132d <read_file_info+0x19d>
movslq -0x834(%rbp),%rax
movzbl -0x420(%rbp,%rax,1),%edi
ff
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     135f <read_file_info+0x1cf>
mov    -0x834(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x834(%rbp)
jmp    132d <read_file_info+0x19d>
lea    -0x830(%rbp),%rdi
lea    -0x420(%rbp),%rsi
movslq -0x834(%rbp),%rax
add    %rax,%rsi
call   1080 <add_file_info@plt>
jmp    11cf <read_file_info+0x3f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12d6 <read_file_info+0x146>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ca <read_file_info+0x13a>
lea    0x10(%rsp),%rbx
lea    0x410(%rsp),%r12
lea    0xc(%rsp),%r13
jmp    120d <read_file_info+0x7d>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%r15)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ca <read_file_info+0x13a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x3ff,%eax
jne    122a <read_file_info+0x9a>
cmpb   $0xa,0x40e(%rsp)
0a
jne    12ed <read_file_info+0x15d>
mov    %eax,%ebp
cltq
lea    (%rsp,%rax,1),%r15
add    $0x10,%r15
cs nopw 0x0(%rax,%rax,1)
test   %ebp,%ebp
jle    11f0 <read_file_info+0x60>
movzbl 0xf(%rsp,%rbp,1),%edi
add    $0xffffffffffffffff,%rbp
call   1050 <isspace@plt>
add    $0xffffffffffffffff,%r15
test   %rax,%rax
jne    1240 <read_file_info+0xb0>
movb   $0x0,0x11(%rsp,%rbp,1)
movl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
lea    0xda8(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    12ff <read_file_info+0x16f>
movslq 0xc(%rsp),%rax
movzbl 0x10(%rsp,%rax,1),%edi
nopl   0x0(%rax)
call   1050 <isspace@plt>
test   %rax,%rax
je     12b0 <read_file_info+0x120>
movslq 0xc(%rsp),%rax
lea    0x1(%rax),%rcx
mov    %ecx,0xc(%rsp)
movzbl 0x11(%rsp,%rax,1),%edi
jmp    1290 <read_file_info+0x100>
xchg   %ax,%ax
movslq 0xc(%rsp),%rax
lea    (%rsp,%rax,1),%rsi
add    $0x10,%rsi
mov    %r12,%rdi
call   1080 <add_file_info@plt>
jmp    11f4 <read_file_info+0x64>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12db <read_file_info+0x14b>
mov    $0xffffffff,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
jmp    130f <read_file_info+0x17f>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"input line is too long\0A\00"
@.str.2 = [5 x i8] c"%s%n\00"
@.str.3 = [20 x i8] c"invalid input file\0A\00"
define i32 @read_file_info(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %14, label %13
13: ; preds = %1
store i32 -1, i32* %2
br label %92
14: ; preds = %1
br label %15
15: ; preds = %82, %61, %14
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i64 @fgets(i8* %16, i32 1024, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %89
20: ; preds = %15
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = icmp eq i64 %24, 1023
br i1 %25, label %26, label %38
26: ; preds = %20
%27 = load i32, i32* %6
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %26, %20
br label %39
39: ; preds = %52, %38
%40 = load i32, i32* %6
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i32, i32* %6
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i64 @isspace(i8 zeroext %47)
%49 = icmp ne i64 %48, 0
br label %50
50: ; preds = %42, %39
%51 = phi i1 [ false, %39 ], [ %49, %42 ]
br i1 %51, label %52, label %55
52: ; preds = %50
%53 = load i32, i32* %6
%54 = add nsw i32 %53, -1
store i32 %54, i32* %6
br label %39
55: ; preds = %50
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %57
store i8 0, i8* %58
%59 = load i32, i32* %6
%60 = icmp sle i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %55
br label %15
62: ; preds = %55
store i32 0, i32* %8
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%65 = call i32 @sscanf(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %64, i32* %8)
%66 = icmp ne i32 %65, 1
br i1 %66, label %67, label %71
67: ; preds = %62
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %62
br label %72
72: ; preds = %79, %71
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = call i64 @isspace(i8 zeroext %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %72
%80 = load i32, i32* %8
%81 = add nsw i32 %80, 1
store i32 %81, i32* %8
br label %72
82: ; preds = %72
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%85 = load i32, i32* %8
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = call i32 @add_file_info(i8* %83, i8* %87)
br label %15
89: ; preds = %15
%90 = load i32*, i32** %4
%91 = call i32 @fclose(i32* %90)
store i32* null, i32** %4
store i32 0, i32* %2
br label %92
92: ; preds = %89, %13
%93 = load i32, i32* %2
ret i32 %93
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"input line is too long\0A\00"
@.str.2 = [5 x i8] c"%s%n\00"
@.str.3 = [20 x i8] c"invalid input file\0A\00"
define i32 @read_file_info(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %75, label %7
7: ; preds = %1
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = call i64 @fgets(i8* %8, i32 1024, i32* %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %73, label %11
11: ; preds = %7
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = bitcast i32* %4 to i8*
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1022
br label %15
15: ; preds = %11, %70
%16 = call i32 @strlen(i8* %8)
%17 = icmp ne i32 %16, 1023
%18 = load i8, i8* %14
%19 = icmp eq i8 %18, 10
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = zext i32 %16 to i64
br label %27
27: ; preds = %35, %25
%28 = phi i64 [ %36, %35 ], [ %26, %25 ]
%29 = trunc i64 %28 to i32
%30 = icmp sgt i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = shl i64 %28, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %33
store i8 0, i8* %34
br label %70
35: ; preds = %27
%36 = add nsw i64 %28, -1
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = call i64 @isspace(i8 zeroext %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %27
41: ; preds = %35
%42 = and i64 %28, 4294967295
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %42
store i8 0, i8* %43
store i32 0, i32* %4
%44 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %12, i32* %4)
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %53
46: ; preds = %41
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = call i64 @isspace(i8 zeroext %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %65, label %57
53: ; preds = %41
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %46, %57
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = call i64 @isspace(i8 zeroext %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %57
65: ; preds = %57, %46
%66 = load i32, i32* %4
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %67
%69 = call i32 @add_file_info(i8* %12, i8* %68)
br label %70
70: ; preds = %31, %65
%71 = call i64 @fgets(i8* %8, i32 1024, i32* %5)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %15
73: ; preds = %70, %7
%74 = call i32 @fclose(i32* %5)
br label %75
75: ; preds = %1, %73
%76 = phi i32 [ 0, %73 ], [ -1, %1 ]
ret i32 %76
}