#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 */
char getchar();
int /*<<< orphan*/ printf(char *, int, ...);
wc_2(void) {
  int c, l, w, ch;
  c = l = w = ch = 1;
  printf("Zii bah ceva %c\n", 33);
  while ((c = getchar()) != '~') {
    switch (c) {
    case '\n':
      l++;
      w++;
      break;
    case ' ':
      w++;
    default:
      ch++;
    }
  }
  while (getchar() != '\n')
    continue;
  printf("Prop ta a avut %d cuvinte cu %i caractere, pe %d linii", w, ch, l);
}


x86 assembly (clang, -O0):
<wc_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x21,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x7e,%eax
je     11c0 <wc_2+0xa0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xa,%eax
je     1192 <wc_2+0x72>
jmp    1181 <wc_2+0x61>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
je     11a9 <wc_2+0x89>
jmp    11b2 <wc_2+0x92>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bb <wc_2+0x9b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <wc_2+0x37>
jmp    11c5 <wc_2+0xa5>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11dd <wc_2+0xbd>
jmp    11c5 <wc_2+0xa5>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wc_2>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%rdi
mov    $0x21,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x1,%r14d
mov    $0x1,%ebp
mov    $0x1,%ebx
cmp    $0x7e,%al
jne    1184 <wc_2+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1160 <wc_2+0x40>
lea    0xe9f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    $0x1,%ebx
mov    $0x1,%ebp
mov    $0x1,%r14d
jmp    11b1 <wc_2+0x91>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x7e,%al
je     1160 <wc_2+0x40>
movsbl %al,%eax
cmp    $0x20,%eax
je     11a0 <wc_2+0x80>
cmp    $0xa,%eax
jne    11a3 <wc_2+0x83>
add    $0x1,%r14d
add    $0x1,%ebp
jmp    11a6 <wc_2+0x86>

LLVM IR (-O0):
@.str = [17 x i8] c"Zii bah ceva %c\0A\00"
@.str.1 = [55 x i8] c"Prop ta a avut %d cuvinte cu %i caractere, pe %d linii\00"
define i32 @wc_2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 1, i32* %5
store i32 1, i32* %4
store i32 1, i32* %3
store i32 1, i32* %2
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 33)
br label %7
7: ; preds = %24, %0
%8 = call signext i8 (...) @getchar()
%9 = sext i8 %8 to i32
store i32 %9, i32* %2
%10 = icmp ne i32 %9, 126
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = load i32, i32* %2
switch i32 %12, label %21 [
i32 10, label %13
i32 32, label %18
]
13: ; preds = %11
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %24
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %11, %18
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %13
br label %7
25: ; preds = %7
br label %26
26: ; preds = %30, %25
%27 = call signext i8 (...) @getchar()
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %26
br label %26
31: ; preds = %26
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [17 x i8] c"Zii bah ceva %c\0A\00"
@.str.1 = [55 x i8] c"Prop ta a avut %d cuvinte cu %i caractere, pe %d linii\00"
define i32 @wc_2() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 33)
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 126
br i1 %3, label %4, label %8
4: ; preds = %22, %0
%5 = phi i32 [ 1, %0 ], [ %23, %22 ]
%6 = phi i32 [ 1, %0 ], [ %24, %22 ]
%7 = phi i32 [ 1, %0 ], [ %25, %22 ]
br label %28
8: ; preds = %0, %22
%9 = phi i8 [ %26, %22 ], [ %2, %0 ]
%10 = phi i32 [ %25, %22 ], [ 1, %0 ]
%11 = phi i32 [ %24, %22 ], [ 1, %0 ]
%12 = phi i32 [ %23, %22 ], [ 1, %0 ]
%13 = sext i8 %9 to i32
switch i32 %13, label %19 [
i32 10, label %14
i32 32, label %17
]
14: ; preds = %8
%15 = add nsw i32 %12, 1
%16 = add nsw i32 %11, 1
br label %22
17: ; preds = %8
%18 = add nsw i32 %11, 1
br label %19
19: ; preds = %8, %17
%20 = phi i32 [ %11, %8 ], [ %18, %17 ]
%21 = add nsw i32 %10, 1
br label %22
22: ; preds = %19, %14
%23 = phi i32 [ %12, %19 ], [ %15, %14 ]
%24 = phi i32 [ %20, %19 ], [ %16, %14 ]
%25 = phi i32 [ %21, %19 ], [ %10, %14 ]
%26 = tail call signext i8 (...) @getchar()
%27 = icmp eq i8 %26, 126
br i1 %27, label %4, label %8
28: ; preds = %4, %28
%29 = tail call signext i8 (...) @getchar()
%30 = icmp eq i8 %29, 10
br i1 %30, label %31, label %28
31: ; preds = %28
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7, i32 %5)
ret i32 undef
}