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


x86 assembly (clang, -O0):
<linear_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11db <linear_search+0xcb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <compare@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
sub    $0xffffffff,%eax
je     117c <linear_search+0x6c>
jmp    114e <linear_search+0x3e>
mov    -0x1c(%rbp),%eax
test   %eax,%eax
je     116f <linear_search+0x5f>
jmp    115e <linear_search+0x4e>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1189 <linear_search+0x79>
jmp    118e <linear_search+0x7e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <linear_search+0xd3>
movq   $0x0,-0x8(%rbp)
jmp    11e3 <linear_search+0xd3>
jmp    118e <linear_search+0x7e>
jmp    1193 <linear_search+0x83>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x1d(%rbp)
jae    11c1 <linear_search+0xb1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11d1 <linear_search+0xc1>
jmp    11d6 <linear_search+0xc6>
jmp    1193 <linear_search+0x83>
jmp    1120 <linear_search+0x10>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_search>:
push   %r14
push   %rbx
push   %rax
cmp    %rsi,%rdi
jae    1163 <linear_search+0x53>
mov    %rsi,%r14
mov    %rdi,%rbx
jmp    113b <linear_search+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
mov    %rax,%rbx
cmp    %r14,%rax
jae    1163 <linear_search+0x53>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <compare@plt>
cmp    $0xffffffff,%eax
je     1163 <linear_search+0x53>
test   %eax,%eax
je     1165 <linear_search+0x55>
nop
cmp    %r14,%rbx
jae    1130 <linear_search+0x20>
lea    0x1(%rbx),%rax
cmpb   $0xa,(%rbx)
mov    %rax,%rbx
jne    1150 <linear_search+0x40>
jmp    1133 <linear_search+0x23>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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