#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 */
scalar_t__ is_range_in_range(int, int);
int /*<<< orphan*/ print_error(char *);
scalar_t__ search_replace(int, char *, char *);
void search_replace_range(int start, int end, char searchstr[80],
                          char replacestr[80]) {
  int i = 0;
  if (is_range_in_range(start, end)) {
    for (i = start; i <= end; i++) {
      if (search_replace(i, searchstr, replacestr) == 0) {
        break;
      }
    }
  } else {
    print_error("lines out of range");
  }
}


x86 assembly (clang, -O0):
<search_replace_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <is_range_in_range@plt>
cmp    $0x0,%rax
je     11ab <search_replace_range+0x7b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a6 <search_replace_range+0x76>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <search_replace@plt>
cmp    $0x0,%rax
jne    1193 <search_replace_range+0x63>
jmp    11a6 <search_replace_range+0x76>
jmp    1198 <search_replace_range+0x68>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <search_replace_range+0x38>
jmp    11b7 <search_replace_range+0x87>
lea    0xe4e(%rip),%rdi
call   1040 <print_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_replace_range>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <is_range_in_range@plt>
test   %rax,%rax
je     1176 <search_replace_range+0x46>
cmp    %ebp,%ebx
jg     116b <search_replace_range+0x3b>
nop
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <search_replace@plt>
test   %rax,%rax
je     116b <search_replace_range+0x3b>
lea    0x1(%rbx),%eax
cmp    %ebx,%ebp
mov    %eax,%ebx
jne    1150 <search_replace_range+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe83(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <print_error@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"lines out of range\00"
define void @search_replace_range(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i64 @is_range_in_range(i32 %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %32
14: ; preds = %4
%15 = load i32, i32* %5
store i32 %15, i32* %9
br label %16
16: ; preds = %28, %14
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load i32, i32* %9
%22 = load i8*, i8** %7
%23 = load i8*, i8** %8
%24 = call i64 @search_replace(i32 %21, i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %31
27: ; preds = %20
br label %28
28: ; preds = %27
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %16
31: ; preds = %26, %16
br label %34
32: ; preds = %4
%33 = call i32 @print_error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32, %31
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"lines out of range\00"
define void @search_replace_range(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i64 @is_range_in_range(i32 %0, i32 %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = icmp sgt i32 %0, %1
br i1 %8, label %18, label %9
9: ; preds = %7, %9
%10 = phi i32 [ %13, %9 ], [ %0, %7 ]
%11 = tail call i64 @search_replace(i32 %10, i8* %2, i8* %3)
%12 = icmp eq i64 %11, 0
%13 = add i32 %10, 1
%14 = icmp eq i32 %10, %1
%15 = or i1 %12, %14
br i1 %15, label %18, label %9
16: ; preds = %4
%17 = tail call i32 @print_error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %9, %7, %16
ret void
}