#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;
  char fnome[51];
  int cl = 0;
  int cb = 0;
  int cp = 0;
  printf("Digite o nome do arquivo: ");
  scanf("%s", fnome);
  arquivo = fopen(fnome, "r");
  c = getc(arquivo);
  while (c != -1) {
    cb++;
    if (c == '\n')
      cl = cl + 1;
    if (c == ' ')
      cp = cp + 1;
    printf("%i %c %x\n", c, c, c);
    c = getc(arquivo);
  }
  printf("L=%i P=%i B=%i\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,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1213 <main+0xc3>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11d8 <main+0x88>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    11eb <main+0x9b>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    11b2 <main+0x62>
mov    -0x54(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%ecx
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xe9d(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <getc@plt>
mov    $0x0,%ebp
mov    $0x0,%ebx
cmp    $0xffffffff,%eax
je     11f5 <main+0xa5>
lea    0xe71(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%r15d
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%ebx
mov    %r12,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <getc@plt>
cmp    $0xffffffff,%eax
jne    11c0 <main+0x70>
lea    0xe2e(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Digite o nome do arquivo: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [10 x i8] c"%i %c %x\0A\00"
@.str.4 = [16 x i8] c"L=%i P=%i B=%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [51 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %3
br label %15
15: ; preds = %32, %0
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %18
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 32
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %3
%34 = load i32, i32* %3
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
%37 = load i32*, i32** %2
%38 = call i32 @getc(i32* %37)
store i32 %38, i32* %3
br label %15
39: ; preds = %15
%40 = load i32, i32* %5
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Digite o nome do arquivo: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [10 x i8] c"%i %c %x\0A\00"
@.str.4 = [16 x i8] c"L=%i P=%i B=%i\0A\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 ([27 x i8], [27 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* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @getc(i32* %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %23, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %19, %8 ], [ 0, %0 ]
%10 = phi i32 [ %13, %8 ], [ 0, %0 ]
%11 = phi i32 [ %16, %8 ], [ 0, %0 ]
%12 = phi i32 [ %21, %8 ], [ %6, %0 ]
%13 = add nuw nsw i32 %10, 1
%14 = icmp eq i32 %12, 10
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %11, %15
%17 = icmp eq i32 %12, 32
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %9, %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %12, i32 %12)
%21 = call i32 @getc(i32* %5)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %8
23: ; preds = %8, %0
%24 = phi i32 [ 0, %0 ], [ %16, %8 ]
%25 = phi i32 [ 0, %0 ], [ %13, %8 ]
%26 = phi i32 [ 0, %0 ], [ %19, %8 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %26, i32 %25)
%28 = call i32 @fclose(i32* %5)
ret i32 0
}