#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 */
typedef int /*<<< orphan*/ u_char;

/* Variables and functions */
int compare(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
u_char *linear_search(u_char *string, u_char *front, u_char *back) {
  int result;
  while (front < back) {
    result = compare(string, front, back);
    if (result == 0)
      return (front);
    if (result < 0)
      return (NULL);
    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    11be <linear_search+0xae>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <compare@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    115d <linear_search+0x4d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c6 <linear_search+0xb6>
cmpl   $0x0,-0x24(%rbp)
jge    1174 <linear_search+0x64>
movq   $0x0,-0x8(%rbp)
jmp    11c6 <linear_search+0xb6>
jmp    1179 <linear_search+0x69>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x25(%rbp)
jae    11a4 <linear_search+0x94>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
cmpl   $0xa,(%rax)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11b4 <linear_search+0xa4>
jmp    11b9 <linear_search+0xa9>
jmp    1179 <linear_search+0x69>
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    1163 <linear_search+0x53>
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    1163 <linear_search+0x53>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <compare@plt>
test   %eax,%eax
je     1165 <linear_search+0x55>
js     1163 <linear_search+0x53>
nop
cmp    %r14,%rbx
jae    1130 <linear_search+0x20>
lea    0x4(%rbx),%rax
cmpl   $0xa,(%rbx)
mov    %rax,%rbx
jne    1150 <linear_search+0x40>
jmp    1133 <linear_search+0x23>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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