#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__ getlines(char *, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strindex(char *, char *);
main() {
  char line[1000];
  char pattern[] = "ould";
  int found = 0;
  while (getlines(line, 1000) > 0) {
    if (strindex(line, pattern) >= 0) {
      printf("%s", line);
      found++;
    }
  }
  return found;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x3f5(%rbp)
mov    0xeb0(%rip),%al
mov    %al,-0x3f1(%rbp)
movl   $0x0,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getlines@plt>
cmp    $0x0,%rax
jle    11c3 <main+0x93>
lea    -0x3f0(%rbp),%rdi
lea    -0x3f5(%rbp),%rsi
call   1040 <strindex@plt>
cmp    $0x0,%rax
jl     11be <main+0x8e>
lea    -0x3f0(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    1164 <main+0x34>
mov    -0x3fc(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3f8,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x646c756f,0x8(%rsp)
64
lea    0x10(%rsp),%rdi
mov    $0x3e8,%esi
call   1050 <getlines@plt>
xor    %ebp,%ebp
test   %rax,%rax
jle    11b2 <main+0x82>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r14
lea    0xe94(%rip),%r15
jmp    1192 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <getlines@plt>
test   %rax,%rax
jle    11b2 <main+0x82>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strindex@plt>
test   %rax,%rax
js     1180 <main+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x1,%ebp
jmp    1180 <main+0x50>
mov    %ebp,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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