#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, int, int);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  FILE *arquivo;
  int c;
  char t[51];
  scanf("%s", t);
  int cl = 0;
  int cb = 0;
  int cp = 0;
  arquivo = fopen(t, "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)
lea    -0x50(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe74(%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     1203 <main+0xb3>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11ca <main+0x7a>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    11dd <main+0x8d>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x54>
mov    -0x54(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%ecx
lea    0xdfc(%rip),%rdi
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
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <getc@plt>
cmp    $0xffffffff,%eax
je     11d5 <main+0x85>
xor    %r15d,%r15d
lea    0xe6e(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%r15d
mov    %r12,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
call   1070 <getc@plt>
cmp    $0xffffffff,%eax
jne    11a0 <main+0x50>
jmp    11dc <main+0x8c>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r15d,%r15d
lea    0xe2c(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
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 = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"%i %c %x\0A\00"
@.str.3 = [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
%8 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %3
br label %14
14: ; preds = %31, %0
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %38
17: ; preds = %14
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %17
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* %3
%33 = load i32, i32* %3
%34 = load i32, i32* %3
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
%36 = load i32*, i32** %2
%37 = call i32 @getc(i32* %36)
store i32 %37, i32* %3
br label %14
38: ; preds = %14
%39 = load i32, i32* %5
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %39, i32 %40, i32 %41)
%43 = load i32*, i32** %2
%44 = call i32 @fclose(i32* %43)
ret i32 0
}

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