#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  FILE *arquivo;
  int c, cl = 0, cb = 0, cp = 0, state = 0, i = 0;
  char fname[51];
  printf("\nDigite o nome completo do arquivo com extensão: ");
  scanf("%s", fname);
  printf("\n\n");
  arquivo = fopen(fname, "r");
  if (arquivo == NULL) {
    printf("O arquivo não pôde ser aberto\n");
    return 0;
  }
  c = getc(arquivo);
  while (c != -1) {
    cb++;
    if (c == '\n') {
      cl++;
    }
    if (c == '\n' || c == ' ' || c == '\t') {
      state = 0;
      i = 0;
    } else {
      i++;
    }
    if (i == 1) {
      state = 1;
      cp++;
    }
    printf("%i %c %x\n", c, c, c);
    c = getc(arquivo);
  }
  printf("L = %d    P = %d    B = %d\n", cl, cp, cb);
  fclose(arquivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e7 <main+0x97>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12bc <main+0x16c>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1295 <main+0x145>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    1219 <main+0xc9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x14(%rbp)
je     1237 <main+0xe7>
cmpl   $0x20,-0x14(%rbp)
je     1237 <main+0xe7>
cmpl   $0x9,-0x14(%rbp)
jne    124a <main+0xfa>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
jmp    1253 <main+0x103>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    126d <main+0x11d>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    11f3 <main+0xa3>
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe8b(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     124e <main+0xee>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <getc@plt>
mov    $0x0,%ebp
mov    $0x0,%ebx
cmp    $0xffffffff,%eax
je     122f <main+0xcf>
xor    %r13d,%r13d
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
nopl   0x0(%rax)
add    $0x1,%ebp
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%r15d
lea    -0x9(%rax),%ecx
add    $0x1,%r12d
cmp    $0x2,%ecx
cmovb  %r13d,%r12d
cmp    $0x20,%eax
cmove  %r13d,%r12d
xor    %ecx,%ecx
cmp    $0x1,%r12d
sete   %cl
add    %ecx,%ebx
lea    0xe23(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1080 <getc@plt>
cmp    $0xffffffff,%eax
jne    11e0 <main+0x80>
lea    0xe0c(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    125a <main+0xfa>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"\0ADigite o nome completo do arquivo com extens\C3\A3o: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [33 x i8] c"O arquivo n\C3\A3o p\C3\B4de ser aberto\0A\00"
@.str.5 = [10 x i8] c"%i %c %x\0A\00"
@.str.6 = [28 x i8] c"L = %d P = %d B = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [51 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %15, i32** %2
%16 = load i32*, i32** %2
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %67
20: ; preds = %0
%21 = load i32*, i32** %2
%22 = call i32 @getc(i32* %21)
store i32 %22, i32* %3
br label %23
23: ; preds = %53, %20
%24 = load i32, i32* %3
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %60
26: ; preds = %23
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 10
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 10
br i1 %36, label %43, label %37
37: ; preds = %34
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 32
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 9
br i1 %42, label %43, label %44
43: ; preds = %40, %37, %34
store i32 0, i32* %7
store i32 0, i32* %8
br label %47
44: ; preds = %40
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %47
47: ; preds = %44, %43
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %53
50: ; preds = %47
store i32 1, i32* %7
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %53
53: ; preds = %50, %47
%54 = load i32, i32* %3
%55 = load i32, i32* %3
%56 = load i32, i32* %3
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %54, i32 %55, i32 %56)
%58 = load i32*, i32** %2
%59 = call i32 @getc(i32* %58)
store i32 %59, i32* %3
br label %23
60: ; preds = %23
%61 = load i32, i32* %4
%62 = load i32, i32* %6
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %61, i32 %62, i32 %63)
%65 = load i32*, i32** %2
%66 = call i32 @fclose(i32* %65)
store i32 0, i32* %1
br label %67
67: ; preds = %60, %18
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [51 x i8] c"\0ADigite o nome completo do arquivo com extens\C3\A3o: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.5 = [10 x i8] c"%i %c %x\0A\00"
@.str.6 = [28 x i8] c"L = %d P = %d B = %d\0A\00"
@str = [2 x i8] c"\0A\00"
@str.7 = [32 x i8] c"O arquivo n\C3\A3o p\C3\B4de ser aberto\00"
define i32 @main() {
%1 = alloca [51 x i8]
%2 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%6 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %41
10: ; preds = %0
%11 = call i32 @getc(i32* %6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %35, label %13
13: ; preds = %10, %13
%14 = phi i32 [ %28, %13 ], [ 0, %10 ]
%15 = phi i32 [ %31, %13 ], [ 0, %10 ]
%16 = phi i32 [ %19, %13 ], [ 0, %10 ]
%17 = phi i32 [ %22, %13 ], [ 0, %10 ]
%18 = phi i32 [ %33, %13 ], [ %11, %10 ]
%19 = add nuw nsw i32 %16, 1
%20 = icmp eq i32 %18, 10
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %17, %21
%23 = icmp eq i32 %18, 32
%24 = add i32 %18, -9
%25 = icmp ult i32 %24, 2
%26 = or i1 %23, %25
%27 = add nsw i32 %14, 1
%28 = select i1 %26, i32 0, i32 %27
%29 = icmp eq i32 %28, 1
%30 = zext i1 %29 to i32
%31 = add nuw nsw i32 %15, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %18, i32 %18)
%33 = call i32 @getc(i32* %6)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %13
35: ; preds = %13, %10
%36 = phi i32 [ 0, %10 ], [ %22, %13 ]
%37 = phi i32 [ 0, %10 ], [ %19, %13 ]
%38 = phi i32 [ 0, %10 ], [ %31, %13 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %36, i32 %38, i32 %37)
%40 = call i32 @fclose(i32* %6)
br label %41
41: ; preds = %35, %8
ret i32 0
}