#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void text_info(char *text) {
  int c, i, state = 0;
  int ch_n = 0, ln_n = 0, ws_n = 0, wd_n = 0;
  for (i = 0; (c = *(text + i)) != 0; i++) {
    ch_n++;
    if (c == '\n')
      ln_n++;
    else if (c == ' ')
      ws_n++;
    if (c == ' ' || c == '\t' || c == '\n')
      state = 0;
    else if (state == 0) {
      state = 1;
      wd_n++;
    }
  }
  printf("%s\n", text);
  printf("\n%d characters\n", --ch_n);
  printf("%d words\n", wd_n);
  printf("%d lines\n", ln_n);
  printf("%d whitespaces\n", ws_n);
}


x86 assembly (clang, -O0):
<text_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11f3 <text_info+0xe3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    117f <text_info+0x6f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1197 <text_info+0x87>
cmpl   $0x20,-0xc(%rbp)
jne    1192 <text_info+0x82>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1197 <text_info+0x87>
cmpl   $0x20,-0xc(%rbp)
je     11b5 <text_info+0xa5>
cmpl   $0x9,-0xc(%rbp)
je     11b5 <text_info+0xa5>
cmpl   $0xa,-0xc(%rbp)
jne    11c1 <text_info+0xb1>
movl   $0x0,-0x14(%rbp)
jmp    11e0 <text_info+0xd0>
cmpl   $0x0,-0x14(%rbp)
jne    11db <text_info+0xcb>
movl   $0x1,-0x14(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <text_info+0xd0>
jmp    11e5 <text_info+0xd5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <text_info+0x36>
mov    -0x8(%rbp),%rsi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x18(%rbp)
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<text_info>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%dl
test   %dl,%dl
je     1188 <text_info+0x68>
lea    0x1(%rdi),%rax
xor    %ebx,%ebx
mov    $0xffffffff,%ebp
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %ecx,%ecx
jmp    1164 <text_info+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15d
xor    %ecx,%ecx
movzbl (%rax),%edx
add    $0x1,%rax
add    $0x1,%ebp
test   %dl,%dl
je     1195 <text_info+0x75>
cmp    $0x9,%dl
je     1154 <text_info+0x34>
cmp    $0x20,%dl
je     1180 <text_info+0x60>
cmp    $0xa,%dl
je     1150 <text_info+0x30>
cmp    $0x1,%ecx
adc    $0x0,%ebx
mov    $0x1,%ecx
jmp    1156 <text_info+0x36>
add    $0x1,%r14d
xor    %ecx,%ecx
jmp    1156 <text_info+0x36>
xor    %r15d,%r15d
mov    $0xffffffff,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
call   1030 <puts@plt>
lea    0xe5f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe52(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [16 x i8] c"\0A%d characters\0A\00"
@.str.2 = [10 x i8] c"%d words\0A\00"
@.str.3 = [10 x i8] c"%d lines\0A\00"
@.str.4 = [16 x i8] c"%d whitespaces\0A\00"
define void @text_info(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %4
br label %10
10: ; preds = %51, %1
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
store i32 %16, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %54
18: ; preds = %10
%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* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %33
26: ; preds = %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* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %23
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 32
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 9
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %39, %36, %33
store i32 0, i32* %5
br label %50
43: ; preds = %39
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
store i32 1, i32* %5
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %49
49: ; preds = %46, %43
br label %50
50: ; preds = %49, %42
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %10
54: ; preds = %10
%55 = load i8*, i8** %2
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %55)
%57 = load i32, i32* %6
%58 = add nsw i32 %57, -1
store i32 %58, i32* %6
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %9
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %7
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %8
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %64)
ret void
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"\0A%d characters\0A\00"
@.str.2 = [10 x i8] c"%d words\0A\00"
@.str.3 = [10 x i8] c"%d lines\0A\00"
@.str.4 = [16 x i8] c"%d whitespaces\0A\00"
define void @text_info(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %30, label %4
4: ; preds = %1, %21
%5 = phi i64 [ %26, %21 ], [ 0, %1 ]
%6 = phi i8 [ %28, %21 ], [ %2, %1 ]
%7 = phi i32 [ %25, %21 ], [ 0, %1 ]
%8 = phi i32 [ %22, %21 ], [ 0, %1 ]
%9 = phi i32 [ %23, %21 ], [ 0, %1 ]
%10 = phi i32 [ %12, %21 ], [ 0, %1 ]
%11 = phi i32 [ %24, %21 ], [ 0, %1 ]
%12 = add nuw nsw i32 %10, 1
switch i8 %6, label %17 [
i8 10, label %13
i8 32, label %15
i8 9, label %21
]
13: ; preds = %4
%14 = add nsw i32 %9, 1
br label %21
15: ; preds = %4
%16 = add nsw i32 %8, 1
br label %21
17: ; preds = %4
%18 = icmp eq i32 %11, 0
%19 = zext i1 %18 to i32
%20 = add nsw i32 %7, %19
br label %21
21: ; preds = %4, %13, %15, %17
%22 = phi i32 [ %8, %17 ], [ %16, %15 ], [ %8, %13 ], [ %8, %4 ]
%23 = phi i32 [ %9, %17 ], [ %9, %15 ], [ %14, %13 ], [ %9, %4 ]
%24 = phi i32 [ 1, %17 ], [ 0, %15 ], [ 0, %13 ], [ 0, %4 ]
%25 = phi i32 [ %20, %17 ], [ %7, %15 ], [ %7, %13 ], [ %7, %4 ]
%26 = add nuw i64 %5, 1
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %4
30: ; preds = %21, %1
%31 = phi i32 [ -1, %1 ], [ %10, %21 ]
%32 = phi i32 [ 0, %1 ], [ %23, %21 ]
%33 = phi i32 [ 0, %1 ], [ %22, %21 ]
%34 = phi i32 [ 0, %1 ], [ %25, %21 ]
%35 = tail call i32 @puts(i8* dereferenceable(1) %0)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret void
}