#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(void) {
  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++;
    }
    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    12a5 <main+0x155>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     127e <main+0x12e>
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    -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    0xdce(%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    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     123a <main+0xda>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <getc@plt>
mov    $0x0,%r13d
mov    $0x0,%ebx
cmp    $0xffffffff,%eax
je     121a <main+0xba>
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
nopl   (%rax)
add    $0x1,%r13d
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%r15d
lea    -0x9(%rax),%ecx
add    $0x1,%ebp
cmp    $0x2,%ecx
cmovb  %r12d,%ebp
cmp    $0x20,%eax
cmove  %r12d,%ebp
xor    %eax,%eax
cmp    $0x1,%ebp
sete   %al
add    %eax,%ebx
mov    %r14,%rdi
call   1080 <getc@plt>
cmp    $0xffffffff,%eax
jne    11e0 <main+0x80>
lea    0xe17(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    1246 <main+0xe6>
lea    0xe13(%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 = [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 %63
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 %56
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** %2
%55 = call i32 @getc(i32* %54)
store i32 %55, i32* %3
br label %23
56: ; preds = %23
%57 = load i32, i32* %4
%58 = load i32, i32* %6
%59 = load i32, i32* %5
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %57, i32 %58, i32 %59)
%61 = load i32*, i32** %2
%62 = call i32 @fclose(i32* %61)
store i32 0, i32* %1
br label %63
63: ; preds = %56, %18
%64 = load i32, i32* %1
ret i32 %64
}

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 = [28 x i8] c"L = %d P = %d B = %d\0A\00"
@str = [2 x i8] c"\0A\00"
@str.6 = [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.6, i64 0, i64 0))
br label %40
10: ; preds = %0
%11 = call i32 @getc(i32* %6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %34, 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 [ %32, %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 @getc(i32* %6)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %13
34: ; preds = %13, %10
%35 = phi i32 [ 0, %10 ], [ %22, %13 ]
%36 = phi i32 [ 0, %10 ], [ %19, %13 ]
%37 = phi i32 [ 0, %10 ], [ %31, %13 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %35, i32 %37, i32 %36)
%39 = call i32 @fclose(i32* %6)
br label %40
40: ; preds = %34, %8
ret i32 0
}