#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ gets(char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(void) {
  char last[80] = "";
  char line[80];
  int lines = 0, chars = 0, match = 0;
  int i;
  while (gets(line)) {
    for (i = 0;; i++) {
      if (line[i] != last[i])
        break;
    }
    lines += 1;
    chars += strlen(line) + 1;
    match += i;
    strcpy(last, line);
  }
  printf("%d lines, %d chars, %d matched chars\n", lines, chars, match);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xbc(%rbp)
lea    -0xb0(%rbp),%rdi
call   1070 <gets@plt>
cmp    $0x0,%rax
je     125a <main+0xfa>
movl   $0x0,-0xc0(%rbp)
movslq -0xc0(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
movslq -0xc0(%rbp),%rcx
movsbl -0x60(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11e8 <main+0x88>
jmp    1201 <main+0xa1>
jmp    11ed <main+0x8d>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    11c0 <main+0x60>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
movslq -0xb8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xb8(%rbp)
mov    -0xc0(%rbp),%eax
add    -0xbc(%rbp),%eax
mov    %eax,-0xbc(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a0 <main+0x40>
mov    -0xb4(%rbp),%esi
mov    -0xb8(%rbp),%edx
mov    -0xbc(%rbp),%ecx
lea    0xd8d(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%rdi
call   1060 <gets@plt>
xor    %r13d,%r13d
mov    $0x0,%ebx
mov    $0x0,%ecx
test   %rax,%rax
je     1209 <main+0xb9>
xor    %r12d,%r12d
lea    0x50(%rsp),%r14
xor    %ebx,%ebx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rax
movzbl 0x50(%rsp,%rbp,1),%ecx
add    $0x1,%rbp
cmp    (%rsp,%rax,1),%cl
je     11c0 <main+0x70>
add    $0x1,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %eax,%ebx
add    $0x1,%ebx
lea    (%r15,%rbp,1),%r12d
add    $0xffffffff,%r12d
mov    %rsp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1060 <gets@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
lea    (%r15,%rbp,1),%ecx
add    $0xffffffff,%ecx
lea    0xdf0(%rip),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"%d lines, %d chars, %d matched chars\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [80 x i8]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %31, %0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = call i64 @gets(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %47
13: ; preds = %9
store i32 0, i32* %7
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %19, %24
br i1 %25, label %26, label %27
26: ; preds = %14
br label %31
27: ; preds = %14
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %14
31: ; preds = %26
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%35 = call i64 @strlen(i8* %34)
%36 = add nsw i64 %35, 1
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = add nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %5
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = add nsw i32 %42, %41
store i32 %43, i32* %6
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%46 = call i32 @strcpy(i8* %44, i8* %45)
br label %9
47: ; preds = %9
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = load i32, i32* %6
%51 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %49, i32 %50)
%52 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [38 x i8] c"%d lines, %d chars, %d matched chars\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = call i64 @gets(i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %30, label %7
7: ; preds = %0, %19
%8 = phi i32 [ %26, %19 ], [ 0, %0 ]
%9 = phi i32 [ %25, %19 ], [ 0, %0 ]
%10 = phi i32 [ %21, %19 ], [ 0, %0 ]
br label %11
11: ; preds = %11, %7
%12 = phi i64 [ %18, %11 ], [ 0, %7 ]
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %14, %16
%18 = add nuw i64 %12, 1
br i1 %17, label %11, label %19
19: ; preds = %11
%20 = trunc i64 %12 to i32
%21 = add nuw nsw i32 %10, 1
%22 = call i64 @strlen(i8* %4)
%23 = trunc i64 %22 to i32
%24 = add i32 %9, 1
%25 = add i32 %24, %23
%26 = add nuw nsw i32 %8, %20
%27 = call i32 @strcpy(i8* %3, i8* %4)
%28 = call i64 @gets(i8* %4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %7
30: ; preds = %19, %0
%31 = phi i32 [ 0, %0 ], [ %21, %19 ]
%32 = phi i32 [ 0, %0 ], [ %25, %19 ]
%33 = phi i32 [ 0, %0 ], [ %26, %19 ]
%34 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = call i32 @exit(i32 0)
unreachable
}