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


x86 assembly (clang, -O0):
<myReduceLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x27c(%rbp)
movl   $0x0,-0x280(%rbp)
lea    -0xd0(%rbp),%rdi
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x278(%rbp)
cmp    $0x0,%rax
je     128c <myReduceLines+0x11c>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     11de <myReduceLines+0x6e>
lea    0xe27(%rip),%rdi
call   1090 <perror@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x1a0(%rbp),%rdx
lea    0xe22(%rip),%rsi
lea    -0x27c(%rbp),%rcx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
jle    1287 <myReduceLines+0x117>
lea    -0x270(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    123d <myReduceLines+0xcd>
mov    -0x27c(%rbp),%eax
add    -0x280(%rbp),%eax
mov    %eax,-0x280(%rbp)
jmp    1282 <myReduceLines+0x112>
cmpl   $0x0,-0x280(%rbp)
je     1263 <myReduceLines+0xf3>
lea    -0x270(%rbp),%rsi
mov    -0x280(%rbp),%edx
lea    0xdbd(%rip),%rdi
call   1050 <printf@plt>
lea    -0x270(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x27c(%rbp),%eax
mov    %eax,-0x280(%rbp)
jmp    1287 <myReduceLines+0x117>
jmp    118f <myReduceLines+0x1f>
lea    -0x270(%rbp),%rsi
mov    -0x280(%rbp),%edx
lea    0xd7b(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     12c9 <myReduceLines+0x159>
lea    0xd3c(%rip),%rdi
call   1090 <perror@plt>
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myReduceLines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x278,%rsp
movl   $0x0,0xc(%rsp)
mov    0x2e58(%rip),%r14
mov    (%r14),%edx
lea    0xe0(%rsp),%rdi
mov    $0xc8,%esi
call   1060 <fgets@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1254 <myReduceLines+0xe4>
lea    0xe0(%rsp),%r15
lea    0x1b0(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x10(%rsp),%rbp
jmp    11e9 <myReduceLines+0x79>
nopl   0x0(%rax)
add    0xc(%rsp),%ebx
mov    (%r14),%edx
mov    %r15,%rdi
mov    $0xc8,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1254 <myReduceLines+0xe4>
mov    (%r14),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1246 <myReduceLines+0xd6>
mov    %r15,%rdi
lea    0xe15(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1080 <sscanf@plt>
test   %rax,%rax
jle    11d4 <myReduceLines+0x64>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11d0 <myReduceLines+0x60>
test   %ebx,%ebx
je     1235 <myReduceLines+0xc5>
lea    0xdf0(%rip),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%ebx
jmp    11d4 <myReduceLines+0x64>
lea    0xdb3(%rip),%rdi
call   1090 <perror@plt>
jmp    11f6 <myReduceLines+0x86>
lea    0xdc0(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %ebx,%edx
call   1050 <printf@plt>
mov    (%r14),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1286 <myReduceLines+0x116>
add    $0x278,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd73(%rip),%rdi
call   1090 <perror@plt>
jmp    1274 <myReduceLines+0x104>

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

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