#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__ get_line(char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strindex(char *, char *);
int main() {
  char s[1000];
  char *to_match = "";
  int total_found = 0;
  while (get_line(s, 1000) > 0) {
    if (strindex(s, to_match) >= 0) {
      printf("%s", s);
      total_found++;
    }
  }
  printf("Total_Found: %d\n", total_found);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x3f8(%rbp)
movl   $0x0,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
jle    11bb <main+0x8b>
lea    -0x3f0(%rbp),%rdi
mov    -0x3f8(%rbp),%rsi
call   1050 <strindex@plt>
cmp    $0x0,%rax
jl     11b6 <main+0x86>
lea    -0x3f0(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    115a <main+0x2a>
mov    -0x3fc(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
test   %rax,%rax
jle    11a4 <main+0x74>
lea    0xebd(%rip),%r14
mov    %rsp,%rbx
lea    0xea0(%rip),%r15
xor    %ebp,%ebp
jmp    1182 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1030 <get_line@plt>
test   %rax,%rax
jle    11a6 <main+0x76>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strindex@plt>
test   %rax,%rax
js     1170 <main+0x40>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    1170 <main+0x40>
xor    %ebp,%ebp
lea    0xe56(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Total_Found: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = call i64 @get_line(i8* %6, i32 1000)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i64 @strindex(i8* %10, i8* %11)
%13 = icmp sge i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %14, %9
br label %5
20: ; preds = %5
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Total_Found: %d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i64 @get_line(i8* %2, i32 1000)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %0, %12
%6 = phi i32 [ %13, %12 ], [ 0, %0 ]
%7 = call i64 @strindex(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp sgt i64 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = add nsw i32 %6, 1
br label %12
12: ; preds = %9, %5
%13 = phi i32 [ %11, %9 ], [ %6, %5 ]
%14 = call i64 @get_line(i8* %2, i32 1000)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %5, label %16
16: ; preds = %12, %0
%17 = phi i32 [ 0, %0 ], [ %13, %12 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}