#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 */
char EOF;
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void fread_Data_c(int *frequency, unsigned char *Number_symbols, FILE *file) {
  char tmp;
  int t = 0;
  while ((tmp = fgetc(file)) != EOF) {
    if (!frequency[tmp]) {
      t++;
    }
    frequency[tmp]++;
  }
  *Number_symbols = t;
  if (fclose(file)) {
    printf("error\n");
    exit(1);
  }
  fprintf(stderr, "0\n");
}


x86 assembly (clang, -O0):
<fread_Data_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e67(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11bf <fread_Data_c+0x6f>
mov    -0x8(%rbp),%rax
movsbq -0x19(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11a8 <fread_Data_c+0x58>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbq -0x19(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    116b <fread_Data_c+0x1b>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     11f3 <fread_Data_c+0xa3>
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fread_Data_c>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1050 <fgetc@plt>
mov    0x2e78(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%al
je     11a1 <fread_Data_c+0x51>
nopl   0x0(%rax,%rax,1)
movsbq %al,%rax
mov    (%rbx,%rax,4),%ecx
cmp    $0x1,%ecx
adc    $0x0,%ebp
add    $0x1,%ecx
mov    %ecx,(%rbx,%rax,4)
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
jne    1180 <fread_Data_c+0x30>
mov    %bpl,(%r14)
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    11ce <fread_Data_c+0x7e>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [7 x i8] c"error\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"0\0A\00"
define void @fread_Data_c(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i32 0, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32*, i32** %6
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %7
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %33
16: ; preds = %9
%17 = load i32*, i32** %4
%18 = load i8, i8* %7
%19 = sext i8 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %26
26: ; preds = %23, %16
%27 = load i32*, i32** %4
%28 = load i8, i8* %7
%29 = sext i8 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %9
33: ; preds = %9
%34 = load i32, i32* %8
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %5
store i8 %35, i8* %36
%37 = load i32*, i32** %6
%38 = call i64 @fclose(i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %33
%41 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %33
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@stderr = global i32 0
@.str.1 = [3 x i8] c"0\0A\00"
@str = [6 x i8] c"error\00"
define void @fread_Data_c(i32* nocapture %0, i8* nocapture writeonly %1, i32* nocapture %2) {
%4 = tail call signext i8 @fgetc(i32* %2)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %22, label %7
7: ; preds = %3, %7
%8 = phi i8 [ %17, %7 ], [ %4, %3 ]
%9 = phi i32 [ %15, %7 ], [ 0, %3 ]
%10 = sext i8 %8 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %9, %14
%16 = add nsw i32 %12, 1
store i32 %16, i32* %11
%17 = tail call signext i8 @fgetc(i32* %2)
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = trunc i32 %15 to i8
br label %22
22: ; preds = %20, %3
%23 = phi i8 [ 0, %3 ], [ %21, %20 ]
store i8 %23, i8* %1
%24 = tail call i64 @fclose(i32* %2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}