#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 EOF;
int /*<<< orphan*/ affiche_entier(int);
int getchar();
scalar_t__ isalnum(int);
int main(void) {
  int etat = 2;
  int nmots = 0;
  int c;
  while ((c = getchar()) != EOF) {
    if (etat == 2) {
      if (isalnum(c)) {
        etat = 1;
        nmots++;
      }
    } else if (etat == 1) {
      if (!isalnum(c)) {
        etat = 2;
      }
    }
  }
  affiche_entier(nmots);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11c9 <main+0x99>
cmpl   $0x2,-0x8(%rbp)
jne    1197 <main+0x67>
mov    -0x10(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     1192 <main+0x62>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c4 <main+0x94>
cmpl   $0x1,-0x8(%rbp)
jne    11bf <main+0x8f>
mov    -0x10(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    11ba <main+0x8a>
movl   $0x2,-0x8(%rbp)
jmp    11bf <main+0x8f>
jmp    11c4 <main+0x94>
jmp    114d <main+0x1d>
mov    -0xc(%rbp),%edi
call   1050 <affiche_entier@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea1(%rip),%r14
cmp    (%r14),%eax
je     1191 <main+0x61>
mov    $0x2,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x2,%ebp
sete   %r15b
mov    %eax,%edi
call   1030 <isalnum@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
setne  %al
and    %r15b,%al
movzbl %al,%eax
add    %eax,%ebx
add    $0x1,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
jne    1160 <main+0x30>
mov    %ebx,%edi
call   1050 <affiche_entier@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %30, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %4
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i32, i32* %4
%14 = call i64 @isalnum(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
store i32 1, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %12
br label %30
20: ; preds = %9
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %4
%25 = call i64 @isalnum(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 2, i32* %2
br label %28
28: ; preds = %27, %23
br label %29
29: ; preds = %28, %20
br label %30
30: ; preds = %29, %19
br label %5
31: ; preds = %5
%32 = load i32, i32* %3
%33 = call i32 @affiche_entier(i32 %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %19, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %16, %4 ], [ %1, %0 ]
%6 = phi i32 [ %15, %4 ], [ 2, %0 ]
%7 = phi i32 [ %14, %4 ], [ 0, %0 ]
%8 = icmp eq i32 %6, 2
%9 = tail call i64 @isalnum(i32 %5)
%10 = icmp eq i64 %9, 0
%11 = xor i1 %10, true
%12 = select i1 %8, i1 %11, i1 false
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %7, %13
%15 = select i1 %10, i32 2, i32 1
%16 = tail call i32 (...) @getchar()
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %4
19: ; preds = %4, %0
%20 = phi i32 [ 0, %0 ], [ %14, %4 ]
%21 = tail call i32 @affiche_entier(i32 %20)
ret i32 0
}