#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 ap_getline(char **, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strstr(char *, char *);
int main(int argc, char **argv) {
  char *target_pos;
  char *line = NULL;
  int len;
  if (argc != 2) {
    fprintf(stderr, "please supply target string\n");
    exit(-1);
  }
  while (!feof(stdin)) {
    len = ap_getline(&line, stdin);
    target_pos = strstr(line, argv[1]);
    if (target_pos)
      printf("%s", target_pos);
    free(line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b7 <main+0x47>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11bc <main+0x4c>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11df <main+0x6f>
jmp    1232 <main+0xc2>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdi
call   1050 <ap_getline@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1224 <main+0xb4>
mov    -0x18(%rbp),%rsi
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    11bc <main+0x4c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    120a <main+0x9a>
mov    %rsi,%r12
mov    0x2e53(%rip),%r13
mov    0x0(%r13),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     11b2 <main+0x42>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x8(%rsp),%r14
lea    0xe5f(%rip),%r15
jmp    11d5 <main+0x65>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x0(%r13),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    11a2 <main+0x32>
mov    0x0(%r13),%esi
mov    %r14,%rdi
call   1050 <ap_getline@plt>
mov    0x8(%rsp),%rbx
mov    0x8(%r12),%rsi
mov    %rbx,%rdi
call   1090 <strstr@plt>
test   %rax,%rax
je     11c0 <main+0x50>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x8(%rsp),%rbx
jmp    11c0 <main+0x50>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"please supply target string\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
br label %16
16: ; preds = %34, %15
%17 = load i32, i32* @stdin
%18 = call i32 @feof(i32 %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %37
21: ; preds = %16
%22 = load i32, i32* @stdin
%23 = call i32 @ap_getline(i8** %7, i32 %22)
store i32 %23, i32* %8
%24 = load i8*, i8** %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i8* @strstr(i8* %24, i8* %27)
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = load i8*, i8** %6
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %21
%35 = load i8*, i8** %7
%36 = call i32 @free(i8* %35)
br label %16
37: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"please supply target string\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @stdin
%8 = call i32 @feof(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 1
br label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %10, %26
%17 = load i32, i32* @stdin
%18 = call i32 @ap_getline(i8** %3, i32 %17)
%19 = load i8*, i8** %3
%20 = load i8*, i8** %11
%21 = call i8* @strstr(i8* dereferenceable(1) %19, i8* dereferenceable(1) %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %26, label %23
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%25 = load i8*, i8** %3
br label %26
26: ; preds = %23, %16
%27 = phi i8* [ %25, %23 ], [ %19, %16 ]
%28 = call i32 @free(i8* %27)
%29 = load i32, i32* @stdin
%30 = call i32 @feof(i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %16, label %32
32: ; preds = %26, %6
ret i32 0
}