#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 compare(char *, char *, char *);
char *linear_search(char *string, char *front, char *back) {
  while (front < back) {
    switch (compare(string, front, back)) {
    case 0:
      return (front);
      break;
    case (-1):
      return (NULL);
      break;
    case 1:
      break;
    }
    while (front < back && *front++ != '\n')
      continue;
    ;
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<linear_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11e3 <linear_search+0xd3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <compare@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
sub    $0xffffffff,%eax
je     1184 <linear_search+0x74>
jmp    1156 <linear_search+0x46>
mov    -0x24(%rbp),%eax
test   %eax,%eax
je     1177 <linear_search+0x67>
jmp    1166 <linear_search+0x56>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     1191 <linear_search+0x81>
jmp    1196 <linear_search+0x86>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <linear_search+0xdb>
movq   $0x0,-0x8(%rbp)
jmp    11eb <linear_search+0xdb>
jmp    1196 <linear_search+0x86>
jmp    119b <linear_search+0x8b>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x25(%rbp)
jae    11c9 <linear_search+0xb9>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11d9 <linear_search+0xc9>
jmp    11de <linear_search+0xce>
jmp    119b <linear_search+0x8b>
jmp    1124 <linear_search+0x14>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_search>:
push   %r15
push   %r14
push   %rbx
cmp    %rdx,%rsi
jae    1173 <linear_search+0x63>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
jmp    113b <linear_search+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rax
mov    %rax,%rbx
cmp    %r14,%rax
jae    1173 <linear_search+0x63>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <compare@plt>
cmp    $0xffffffff,%eax
je     1173 <linear_search+0x63>
test   %eax,%eax
je     1175 <linear_search+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r14,%rbx
jae    1130 <linear_search+0x20>
lea    0x1(%rbx),%rax
cmpb   $0xa,(%rbx)
mov    %rax,%rbx
jne    1160 <linear_search+0x50>
jmp    1133 <linear_search+0x23>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @linear_search(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
br label %8
8: ; preds = %35, %3
%9 = load i8*, i8** %6
%10 = load i8*, i8** %7
%11 = icmp ult i8* %9, %10
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i8*, i8** %7
%16 = call i32 @compare(i8* %13, i8* %14, i8* %15)
switch i32 %16, label %21 [
i32 0, label %17
i32 -1, label %19
i32 1, label %20
]
17: ; preds = %12
%18 = load i8*, i8** %6
store i8* %18, i8** %4
br label %37
19: ; preds = %12
store i8* null, i8** %4
br label %37
20: ; preds = %12
br label %21
21: ; preds = %12, %20
br label %22
22: ; preds = %34, %21
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = icmp ult i8* %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %6
%29 = load i8, i8* %27
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 10
br label %32
32: ; preds = %26, %22
%33 = phi i1 [ false, %22 ], [ %31, %26 ]
br i1 %33, label %34, label %35
34: ; preds = %32
br label %22
35: ; preds = %32
br label %8
36: ; preds = %8
store i8* null, i8** %4
br label %37
37: ; preds = %36, %19, %17
%38 = load i8*, i8** %4
ret i8* %38
}

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