#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 */
scalar_t__ EOF;
int count(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char str[256];
  int total = 0;
  int temp;
  FILE *fp = fopen("FileList.txt", "rt");
  while (fscanf(fp, "%s", str) != EOF) {
    temp = count(str);
    printf("%s: %d\n", str, temp);
    total += temp;
  }
  printf("total: %d\n", total);
  getchar();
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
lea    0xe7d(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2e31(%rip),%rcx
cmp    (%rcx),%rax
je     1204 <main+0xa4>
lea    -0x110(%rbp),%rdi
call   1030 <count@plt>
mov    %eax,-0x118(%rbp)
lea    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%edx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x118(%rbp),%eax
add    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
jmp    1196 <main+0x36>
mov    -0x114(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x120(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe82(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0x2e48(%rip),%r15
xor    %ebp,%ebp
cmp    (%r15),%rax
je     11f2 <main+0x92>
mov    %rsp,%r13
lea    0xe5f(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1030 <count@plt>
mov    %eax,%ebx
lea    0xe42(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    %ebx,%ebp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
cmp    (%r15),%rax
jne    11c0 <main+0x60>
lea    0xe22(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"FileList.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [8 x i8] c"%s: %d\0A\00"
@.str.4 = [11 x i8] c"total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %3
%6 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
br label %7
7: ; preds = %13, %0
%8 = load i32*, i32** %5
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%10 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %7
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = call i32 @count(i8* %14)
store i32 %15, i32* %4
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %16, i32 %17)
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
br label %7
22: ; preds = %7
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = call i32 (...) @getchar()
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"FileList.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [8 x i8] c"%s: %d\0A\00"
@.str.4 = [11 x i8] c"total: %d\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ 0, %0 ]
%9 = call i32 @count(i8* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %9)
%11 = add nsw i32 %9, %8
%12 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %7
15: ; preds = %7, %0
%16 = phi i32 [ 0, %0 ], [ %11, %7 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @getchar()
%19 = call i32 @fclose(i32* %3)
ret i32 0
}