#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(int argc, char **argv) {
  FILE *arq;
  arq = fopen(argv[1], "r");
  int l = 0, p = 0, c = 0;
  char ch;
  while ((ch = fgetc(arq)) != EOF) {
    if (ch == '\n')
      l++;
    if (ch == ' ')
      p++;
    c++;
  }
  p += l;
  printf("%d %d %d\n", l, p, c);
  fclose(arq);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2e4f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11de <main+0x9e>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    11ba <main+0x7a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    11d0 <main+0x90>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <main+0x43>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x8(%rsi),%rdi
lea    0xead(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e7e(%rip),%r12
xor    %ebp,%ebp
mov    $0x0,%r15d
mov    $0x0,%ebx
cmp    (%r12),%al
je     11b4 <main+0x74>
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0x20,%al
sete   %cl
add    %ecx,%ebp
add    $0x1,%r15d
mov    %r14,%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
jne    1190 <main+0x50>
add    %ebx,%ebp
lea    0xe45(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%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 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %36, %2
%16 = load i32*, i32** %6
%17 = call signext i8 @fgetc(i32* %16)
store i8 %17, i8* %10
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %39
22: ; preds = %15
%23 = load i8, i8* %10
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %22
%30 = load i8, i8* %10
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %36
36: ; preds = %33, %29
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %15
39: ; preds = %15
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = add nsw i32 %41, %40
store i32 %42, i32* %8
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = load i32, i32* %9
%46 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call signext i8 @fgetc(i32* %5)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %24, label %9
9: ; preds = %2, %9
%10 = phi i8 [ %21, %9 ], [ %6, %2 ]
%11 = phi i32 [ %16, %9 ], [ 0, %2 ]
%12 = phi i32 [ %20, %9 ], [ 0, %2 ]
%13 = phi i32 [ %19, %9 ], [ 0, %2 ]
%14 = icmp eq i8 %10, 10
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %11, %15
%17 = icmp eq i8 %10, 32
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %13, %18
%20 = add nuw nsw i32 %12, 1
%21 = tail call signext i8 @fgetc(i32* %5)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %9
24: ; preds = %9, %2
%25 = phi i32 [ 0, %2 ], [ %19, %9 ]
%26 = phi i32 [ 0, %2 ], [ %20, %9 ]
%27 = phi i32 [ 0, %2 ], [ %16, %9 ]
%28 = add nuw nsw i32 %27, %25
%29 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28, i32 %26)
%30 = tail call i32 @fclose(i32* %5)
ret i32 0
}