#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int i, wcnt;
  FILE *in;
  char ch;
  char pch;
  if (argc < 2) {
    fprintf(stderr, "Missing input file(s).\n");
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    in = fopen(argv[i], "r");
    if (in == NULL) {
      perror(argv[i]);
      continue;
    }
    wcnt = 0;
    pch = ch = 'a';
    while ((ch = fgetc(in)) != EOF) {
      if (isspace(ch)) {
        if (!isspace(pch)) {
          wcnt++;
        } else {
          continue;
        }
        pch = ' ';
      } else {
        pch = ch;
      }
    }
    printf("%s: %d word(s).\n", argv[i], wcnt);
    fclose(in);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11bf <main+0x3f>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12be <main+0x13e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe33(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120f <main+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <perror@plt>
jmp    12b0 <main+0x130>
movl   $0x0,-0x18(%rbp)
movb   $0x61,-0x21(%rbp)
movb   $0x61,-0x22(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2db4(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     128c <main+0x10c>
movsbl -0x21(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     1281 <main+0x101>
movsbl -0x22(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
jne    1273 <main+0xf3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1278 <main+0xf8>
jmp    121e <main+0x9e>
movb   $0x20,-0x22(%rbp)
jmp    1287 <main+0x107>
mov    -0x21(%rbp),%al
mov    %al,-0x22(%rbp)
jmp    121e <main+0x9e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%edx
lea    0xd78(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c6 <main+0x46>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     126d <main+0xed>
mov    %rsi,%rbx
mov    %edi,%eax
mov    %rax,0x10(%rsp)
mov    $0x1,%r14d
mov    0x2e3a(%rip),%r15
mov    %rsi,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx,%r14,8),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1251 <main+0xd1>
mov    %rax,%rbp
mov    $0x61,%r12b
xor    %r13d,%r13d
xchg   %ax,%ax
mov    %rbp,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%al
je     1220 <main+0xa0>
mov    %eax,%ebx
movsbl %al,%edi
call   1060 <isspace@plt>
test   %rax,%rax
je     1213 <main+0x93>
movsbl %r12b,%edi
call   1060 <isspace@plt>
test   %rax,%rax
jne    11e0 <main+0x60>
add    $0x1,%r13d
mov    $0x20,%r12b
jmp    11e0 <main+0x60>
mov    %ebx,%r12d
jmp    11e0 <main+0x60>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rbx
mov    (%rbx,%r14,8),%rsi
lea    0xdea(%rip),%rdi
mov    %r13d,%edx
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x1,%r14
cmp    0x10(%rsp),%r14
jne    11c0 <main+0x40>
jmp    125c <main+0xdc>
mov    (%rbx,%r14,8),%rdi
call   1090 <perror@plt>
jmp    1240 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Missing input file(s).\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [17 x i8] c"%s: %d word(s).\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 i8
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
store i32 1, i32* %6
br label %18
18: ; preds = %72, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %75
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %8
%29 = load i32*, i32** %8
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %38
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @perror(i8* %36)
br label %72
38: ; preds = %22
store i32 0, i32* %7
store i8 97, i8* %9
store i8 97, i8* %10
br label %39
39: ; preds = %61, %57, %38
%40 = load i32*, i32** %8
%41 = call signext i8 @fgetc(i32* %40)
store i8 %41, i8* %9
%42 = sext i8 %41 to i32
%43 = load i8, i8* @EOF
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %42, %44
br i1 %45, label %46, label %62
46: ; preds = %39
%47 = load i8, i8* %9
%48 = call i64 @isspace(i8 signext %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %46
%51 = load i8, i8* %10
%52 = call i64 @isspace(i8 signext %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %50
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %58
57: ; preds = %50
br label %39
58: ; preds = %54
store i8 32, i8* %10
br label %61
59: ; preds = %46
%60 = load i8, i8* %9
store i8 %60, i8* %10
br label %61
61: ; preds = %59, %58
br label %39
62: ; preds = %39
%63 = load i8**, i8*** %5
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = load i32, i32* %7
%69 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %67, i32 %68)
%70 = load i32*, i32** %8
%71 = call i32 @fclose(i32* %70)
br label %72
72: ; preds = %62, %31
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
br label %18
75: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Missing input file(s).\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [17 x i8] c"%s: %d word(s).\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %4, %40
%11 = phi i64 [ 1, %4 ], [ %41, %40 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %31
16: ; preds = %10
%17 = load i8*, i8** %12
%18 = tail call i32 @perror(i8* %17)
br label %40
19: ; preds = %34, %26
%20 = tail call signext i8 @fgetc(i32* %14)
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %36, label %23
23: ; preds = %19
%24 = tail call i64 @isspace(i8 signext %20)
%25 = icmp eq i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %23
%27 = tail call i64 @isspace(i8 signext %35)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %19
29: ; preds = %26
%30 = add nuw nsw i32 %32, 1
br label %31
31: ; preds = %10, %29
%32 = phi i32 [ %30, %29 ], [ 0, %10 ]
%33 = phi i8 [ 32, %29 ], [ 97, %10 ]
br label %34
34: ; preds = %23, %31
%35 = phi i8 [ %33, %31 ], [ %20, %23 ]
br label %19
36: ; preds = %19
%37 = load i8*, i8** %12
%38 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 %32)
%39 = tail call i32 @fclose(i32* %14)
br label %40
40: ; preds = %36, %16
%41 = add nuw nsw i64 %11, 1
%42 = icmp eq i64 %41, %5
br i1 %42, label %43, label %10
43: ; preds = %40
ret i32 0
}