#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 strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int line_search(char *line, char *search) {
  int len;
  if (line == NULL || search == NULL || !*search)
    return 0;
  len = strlen(search);
  while (*line) {
    if (*line == '\n')
      break;
    if (*line == *search && !strncmp(line, search, len))
      return 0;
    line++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<line_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1153 <line_search+0x33>
cmpq   $0x0,-0x18(%rbp)
je     1153 <line_search+0x33>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    115f <line_search+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <line_search+0xc0>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d9 <line_search+0xb9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    118d <line_search+0x6d>
jmp    11d9 <line_search+0xb9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11c8 <line_search+0xa8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11c8 <line_search+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <line_search+0xc0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116b <line_search+0x4b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_search>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     117b <line_search+0x5b>
mov    %rsi,%r14
test   %rsi,%rsi
je     117b <line_search+0x5b>
cmpb   $0x0,(%r14)
je     117b <line_search+0x5b>
mov    %rdi,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
jmp    1154 <line_search+0x34>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%ecx
mov    $0x1,%eax
test   %cl,%cl
je     117d <line_search+0x5d>
cmp    $0xa,%cl
je     117d <line_search+0x5d>
cmp    (%r14),%cl
jne    1150 <line_search+0x30>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1150 <line_search+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @line_search(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12, %9, %2
store i32 0, i32* %3
br label %49
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %6
br label %20
20: ; preds = %45, %17
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %30
29: ; preds = %24
br label %48
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %33, %36
br i1 %37, label %38, label %45
38: ; preds = %30
%39 = load i8*, i8** %4
%40 = load i8*, i8** %5
%41 = load i32, i32* %6
%42 = call i32 @strncmp(i8* %39, i8* %40, i32 %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %38
store i32 0, i32* %3
br label %49
45: ; preds = %38, %30
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
br label %20
48: ; preds = %29, %20
store i32 1, i32* %3
br label %49
49: ; preds = %48, %44, %16
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
define i32 @line_search(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %1)
br label %11
11: ; preds = %20, %9
%12 = phi i8* [ %0, %9 ], [ %21, %20 ]
%13 = load i8, i8* %12
switch i8 %13, label %14 [
i8 0, label %22
i8 10, label %22
]
14: ; preds = %11
%15 = load i8, i8* %1
%16 = icmp eq i8 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 @strncmp(i8* %12, i8* %1, i32 %10)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17, %14
%21 = getelementptr inbounds i8, i8* %12, i64 1
br label %11
22: ; preds = %11, %11, %17, %2, %6
%23 = phi i32 [ 0, %6 ], [ 0, %2 ], [ 1, %11 ], [ 1, %11 ], [ 0, %17 ]
ret i32 %23
}