#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int smatch(char *, char *);
int main(void) {
  int c;
  char src[1000];
  char mtch[1000];
  int pos = 0;
  mtch[0] = 'a';
  mtch[1] = 'b';
  mtch[2] = 'c';
  mtch[3] = 'd';
  mtch[4] = '\0';
  while ((c = getchar()) != EOF) {
    if (c == '\n' || pos == 1000 - 1) {
      if (pos < 1000) {
        src[pos] = '\0';
        printf("%d\n", smatch(src, mtch));
      }
      if (c == '\n') {
        pos = 0;
      } else if (pos == 1000 - 1) {
        pos = 1000;
      }
    } else if (pos < 1000 - 1) {
      src[pos++] = c;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e4(%rbp)
movb   $0x61,-0x7e0(%rbp)
movb   $0x62,-0x7df(%rbp)
movb   $0x63,-0x7de(%rbp)
movb   $0x64,-0x7dd(%rbp)
movb   $0x0,-0x7dc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
je     1258 <main+0x128>
cmpl   $0xa,-0x8(%rbp)
je     11a2 <main+0x72>
cmpl   $0x3e7,-0x7e4(%rbp)
jne    121f <main+0xef>
cmpl   $0x3e8,-0x7e4(%rbp)
jge    11e2 <main+0xb2>
movslq -0x7e4(%rbp),%rax
movb   $0x0,-0x3f0(%rbp,%rax,1)
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
call   1030 <smatch@plt>
mov    %eax,%esi
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jne    11fb <main+0xcb>
movl   $0x0,-0x7e4(%rbp)
jmp    121a <main+0xea>
cmpl   $0x3e7,-0x7e4(%rbp)
jne    1215 <main+0xe5>
movl   $0x3e8,-0x7e4(%rbp)
jmp    121a <main+0xea>
jmp    1253 <main+0x123>
cmpl   $0x3e7,-0x7e4(%rbp)
jge    124e <main+0x11e>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x7e4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x7e4(%rbp)
cltq
mov    %cl,-0x3f0(%rbp,%rax,1)
jmp    1253 <main+0x123>
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
movl   $0x64636261,(%rsp)
movb   $0x0,0x4(%rsp)
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8a(%rip),%rbx
cmp    (%rbx),%eax
jne    1176 <main+0x46>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe81(%rip),%r12
mov    $0x3e8,%r14d
xor    %r15d,%r15d
jmp    11af <main+0x7f>
nopw   0x0(%rax,%rax,1)
cmp    $0x3e7,%r15d
cmove  %r14d,%r15d
cmp    $0xa,%ebp
cmove  %r13d,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1162 <main+0x32>
cmp    $0xa,%ebp
je     11d0 <main+0xa0>
cmp    $0x3e7,%r15d
je     11d0 <main+0xa0>
jge    11a2 <main+0x72>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %bpl,0x3f0(%rsp,%rax,1)
jmp    11a2 <main+0x72>
cmp    $0x3e7,%r15d
jg     1190 <main+0x60>
movslq %r15d,%rax
movb   $0x0,0x3f0(%rsp,%rax,1)
lea    0x3f0(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <smatch@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1190 <main+0x60>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 97, i8* %4
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 1
store i8 98, i8* %5
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 2
store i8 99, i8* %6
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 3
store i8 100, i8* %7
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 4
store i8 0, i8* %8
%9 = call i32 (...) @getchar()
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %40, label %12
12: ; preds = %0, %35
%13 = phi i32 [ %37, %35 ], [ %9, %0 ]
%14 = phi i32 [ %36, %35 ], [ 0, %0 ]
%15 = icmp eq i32 %13, 10
%16 = icmp eq i32 %14, 999
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = icmp slt i32 %14, 1000
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = sext i32 %14 to i64
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @smatch(i8* %3, i8* %4)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20, %18
%26 = select i1 %16, i32 1000, i32 %14
%27 = select i1 %15, i32 0, i32 %26
br label %35
28: ; preds = %12
%29 = icmp slt i32 %14, 999
br i1 %29, label %30, label %35
30: ; preds = %28
%31 = trunc i32 %13 to i8
%32 = add nsw i32 %14, 1
%33 = sext i32 %14 to i64
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %33
store i8 %31, i8* %34
br label %35
35: ; preds = %25, %28, %30
%36 = phi i32 [ %32, %30 ], [ %14, %28 ], [ %27, %25 ]
%37 = call i32 (...) @getchar()
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %12
40: ; preds = %35, %0
ret i32 0
}