#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__ getline_my(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char *argv[]) {
  char line[1000];
  int found = 0;
  if (argc != 2) {
    printf("Usage: find pattern.\n");
  } else {
    while (getline_my(line, 1000) > 0) {
      if (strstr(line, argv[1]) != NULL) {
        printf("pattern fount in string = %s\n", line);
        found++;
      }
    }
    return found;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x404(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1170 <main+0x40>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <main+0xb0>
jmp    1175 <main+0x45>
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getline_my@plt>
cmp    $0x0,%rax
jle    11d7 <main+0xa7>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11d2 <main+0xa2>
lea    -0x400(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    1175 <main+0x45>
mov    -0x404(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
cmp    $0x2,%edi
jne    11b5 <main+0x75>
mov    %rsi,%r14
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
test   %rax,%rax
jle    11c1 <main+0x81>
mov    %rsp,%rbx
lea    0xe8f(%rip),%r15
xor    %ebp,%ebp
jmp    1192 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <getline_my@plt>
test   %rax,%rax
jle    11c3 <main+0x83>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    1180 <main+0x40>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Usage: find pattern.\0A\00"
@.str.1 = [30 x i8] c"pattern fount in string = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %32
12: ; preds = %2
br label %13
13: ; preds = %29, %12
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%15 = call i64 @getline_my(i8* %14, i32 1000)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @strstr(i8* %18, i8* %21)
%23 = icmp ne i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %24, %17
br label %13
30: ; preds = %13
%31 = load i32, i32* %7
store i32 %31, i32* %3
br label %32
32: ; preds = %30, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"pattern fount in string = %s\0A\00"
@str = [21 x i8] c"Usage: find pattern.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = call i64 @getline_my(i8* %4, i32 1000)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = getelementptr inbounds i8*, i8** %1, i64 1
br label %13
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %25
13: ; preds = %9, %21
%14 = phi i32 [ 0, %9 ], [ %22, %21 ]
%15 = load i8*, i8** %10
%16 = call i32* @strstr(i8* %4, i8* dereferenceable(1) %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%20 = add nsw i32 %14, 1
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %20, %18 ], [ %14, %13 ]
%23 = call i64 @getline_my(i8* %4, i32 1000)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %13, label %25
25: ; preds = %21, %6, %11
%26 = phi i32 [ 0, %11 ], [ 0, %6 ], [ %22, %21 ]
ret i32 %26
}