#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 */
scalar_t__ ferror(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isdigit(char);
scalar_t__ ispunct(char);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ sscanf(char *, char *, char *, int *);
int /*<<< orphan*/ stdin;
char tolower(char);
void myMapLines(void) {
  char line[200];
  char word[200];
  char *result;
  int n = 0;
  int idx = 0;
  while ((result = fgets(line, 200, stdin)) != NULL) {
    if (ferror(stdin)) {
      perror("Error reading stdin.");
    }
    while (line[idx]) {
      line[idx] = tolower(line[idx]);
      if (ispunct(line[idx]) || isdigit(line[idx])) {
        line[idx] = ' ';
      }
      idx++;
    }
    idx = 0;
    while (sscanf(&line[idx], "%s%n", word, &n) > 0) {
      idx += n;
      printf("%s\t%d\n", word, 1);
    }
    idx = 0;
  }
  if (ferror(stdin)) {
    perror("Error reading stdin.");
  }
}


x86 assembly (clang, -O0):
<myMapLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x1ac(%rbp)
movl   $0x0,-0x1b0(%rbp)
lea    -0xd0(%rbp),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1070 <fgets@plt>
mov    %rax,-0x1a8(%rbp)
cmp    $0x0,%rax
je     1308 <myMapLines+0x188>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     11ee <myMapLines+0x6e>
lea    0xe17(%rip),%rdi
call   10a0 <perror@plt>
jmp    11f3 <myMapLines+0x73>
movslq -0x1b0(%rbp),%rax
cmpb   $0x0,-0xd0(%rbp,%rax,1)
je     128b <myMapLines+0x10b>
movslq -0x1b0(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1080 <tolower@plt>
mov    %al,%cl
movslq -0x1b0(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
movslq -0x1b0(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1060 <ispunct@plt>
cmp    $0x0,%rax
jne    1268 <myMapLines+0xe8>
movslq -0x1b0(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1277 <myMapLines+0xf7>
movslq -0x1b0(%rbp),%rax
movb   $0x20,-0xd0(%rbp,%rax,1)
20
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    11f3 <myMapLines+0x73>
movl   $0x0,-0x1b0(%rbp)
movslq -0x1b0(%rbp),%rax
lea    -0xd0(%rbp),%rdi
add    %rax,%rdi
lea    -0x1a0(%rbp),%rdx
lea    0xd61(%rip),%rsi
lea    -0x1ac(%rbp),%rcx
call   1090 <sscanf@plt>
cmp    $0x0,%rax
jle    12f9 <myMapLines+0x179>
mov    -0x1ac(%rbp),%eax
add    -0x1b0(%rbp),%eax
mov    %eax,-0x1b0(%rbp)
lea    -0x1a0(%rbp),%rsi
lea    0xd30(%rip),%rdi
mov    $0x1,%edx
call   1050 <printf@plt>
jmp    1295 <myMapLines+0x115>
movl   $0x0,-0x1b0(%rbp)
jmp    119f <myMapLines+0x1f>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     132c <myMapLines+0x1ac>
lea    0xcd9(%rip),%rdi
call   10a0 <perror@plt>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myMapLines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
movl   $0x0,0xc(%rsp)
mov    0x2e48(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     12dc <myMapLines+0x15c>
lea    0xe53(%rip),%r15
lea    0xe0(%rsp),%rbx
lea    0xc(%rsp),%r12
lea    0xe44(%rip),%r13
jmp    1202 <myMapLines+0x82>
nopl   0x0(%rax,%rax,1)
mov    0x2e01(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     12dc <myMapLines+0x15c>
mov    0x0(%rbp),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    12cb <myMapLines+0x14b>
mov    0x10(%rsp),%al
test   %al,%al
je     1270 <myMapLines+0xf0>
lea    0x10(%rsp),%r14
jmp    1241 <myMapLines+0xc1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x20,(%r14)
movzbl 0x1(%r14),%eax
add    $0x1,%r14
test   %al,%al
je     1270 <myMapLines+0xf0>
movsbl %al,%edi
call   1080 <tolower@plt>
mov    %al,(%r14)
movsbl %al,%edi
call   1060 <ispunct@plt>
test   %rax,%rax
jne    1230 <myMapLines+0xb0>
movsbl (%r14),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1230 <myMapLines+0xb0>
jmp    1234 <myMapLines+0xb4>
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1090 <sscanf@plt>
test   %rax,%rax
jle    11e0 <myMapLines+0x60>
xor    %ebp,%ebp
xchg   %ax,%ax
movslq 0xc(%rsp),%rax
movslq %ebp,%rbp
add    %rax,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <printf@plt>
lea    (%rsp,%rbp,1),%rdi
add    $0x10,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1090 <sscanf@plt>
test   %rax,%rax
jg     1290 <myMapLines+0x110>
jmp    11e0 <myMapLines+0x60>
lea    0xd2e(%rip),%rdi
call   10a0 <perror@plt>
jmp    1213 <myMapLines+0x93>
mov    0x0(%rbp),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    12fb <myMapLines+0x17b>
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcfe(%rip),%rdi
call   10a0 <perror@plt>
jmp    12e9 <myMapLines+0x169>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [21 x i8] c"Error reading stdin.\00"
@.str.1 = [5 x i8] c"%s%n\00"
@.str.2 = [7 x i8] c"%s\09%d\0A\00"
define void @myMapLines() {
%1 = alloca [200 x i8]
%2 = alloca [200 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %67, %0
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i8* @fgets(i8* %7, i32 200, i32 %8)
store i8* %9, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %68
11: ; preds = %6
%12 = load i32, i32* @stdin
%13 = call i64 @ferror(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
br label %18
18: ; preds = %50, %17
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %18
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call signext i8 @tolower(i8 signext %28)
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %31
store i8 %29, i8* %32
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i64 @ispunct(i8 signext %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %46, label %39
39: ; preds = %24
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = call i64 @isdigit(i8 signext %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %39, %24
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %48
store i8 32, i8* %49
br label %50
50: ; preds = %46, %39
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %18
53: ; preds = %18
store i32 0, i32* %5
br label %54
54: ; preds = %61, %53
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %56
%58 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%59 = call i64 @sscanf(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %58, i32* %4)
%60 = icmp sgt i64 %59, 0
br i1 %60, label %61, label %67
61: ; preds = %54
%62 = load i32, i32* %4
%63 = load i32, i32* %5
%64 = add nsw i32 %63, %62
store i32 %64, i32* %5
%65 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%66 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %65, i32 1)
br label %54
67: ; preds = %54
store i32 0, i32* %5
br label %6
68: ; preds = %6
%69 = load i32, i32* @stdin
%70 = call i64 @ferror(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [21 x i8] c"Error reading stdin.\00"
@.str.1 = [5 x i8] c"%s%n\00"
@.str.2 = [7 x i8] c"%s\09%d\0A\00"
define void @myMapLines() {
%1 = alloca [200 x i8]
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = load i32, i32* @stdin
%8 = call i8* @fgets(i8* %4, i32 200, i32 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %52, label %14
10: ; preds = %43, %23
%11 = load i32, i32* @stdin
%12 = call i8* @fgets(i8* %4, i32 200, i32 %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %52, label %14
14: ; preds = %0, %10
%15 = load i32, i32* @stdin
%16 = call i64 @ferror(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i8, i8* %4
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %38, %20
%24 = call i64 @sscanf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %3)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %43, label %10
26: ; preds = %20, %38
%27 = phi i64 [ %39, %38 ], [ 0, %20 ]
%28 = phi i8 [ %41, %38 ], [ %21, %20 ]
%29 = phi i8* [ %40, %38 ], [ %4, %20 ]
%30 = call signext i8 @tolower(i8 signext %28)
store i8 %30, i8* %29
%31 = call i64 @ispunct(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %26
%34 = load i8, i8* %29
%35 = call i64 @isdigit(i8 signext %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %33, %26
store i8 32, i8* %29
br label %38
38: ; preds = %37, %33
%39 = add nuw i64 %27, 1
%40 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %23, label %26
43: ; preds = %23, %43
%44 = phi i32 [ %46, %43 ], [ 0, %23 ]
%45 = load i32, i32* %3
%46 = add nsw i32 %45, %44
%47 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 1)
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %48
%50 = call i64 @sscanf(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32* %3)
%51 = icmp sgt i64 %50, 0
br i1 %51, label %43, label %10
52: ; preds = %10, %0
%53 = load i32, i32* @stdin
%54 = call i64 @ferror(i32 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %58
58: ; preds = %56, %52
ret void
}