#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 main() {
  FILE *arquivo;
  int c;
  int cl = 0;
  int cb = 0;
  int cp = 0;
  arquivo = fopen("fatorial.c", "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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe95(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11e6 <main+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11ad <main+0x6d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    11c0 <main+0x80>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    1187 <main+0x47>
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeb1(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <getc@plt>
cmp    $0xffffffff,%eax
je     11b5 <main+0x75>
xor    %r15d,%r15d
lea    0xe98(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
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   1060 <getc@plt>
cmp    $0xffffffff,%eax
jne    1180 <main+0x40>
jmp    11bc <main+0x7c>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r15d,%r15d
lea    0xe54(%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
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"fatorial.c\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 i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = call i32 @getc(i32* %8)
store i32 %9, i32* %3
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %18, %13
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 32
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %27
27: ; preds = %24, %21
%28 = load i32, i32* %3
%29 = load i32, i32* %3
%30 = load i32, i32* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
%32 = load i32*, i32** %2
%33 = call i32 @getc(i32* %32)
store i32 %33, i32* %3
br label %10
34: ; preds = %10
%35 = load i32, i32* %4
%36 = load i32, i32* %6
%37 = load i32, i32* %5
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
%39 = load i32*, i32** %2
%40 = call i32 @fclose(i32* %39)
ret i32 0
}

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