#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 RMQUtil(int *, int /*<<< orphan*/, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int RMQ(int *st, int n, int qs, int qe) {
  if (qs < 0 || qe > n - 1 || qs > qe) {
    printf("Invalid input\n");
    return -1;
  }
  return RMQUtil(st, 0, n - 1, qs, qe, 0);
}


x86 assembly (clang, -O0):
<RMQ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     115c <RMQ+0x3c>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     115c <RMQ+0x3c>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1174 <RMQ+0x54>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <RMQ+0x73>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%esi
call   1040 <RMQUtil@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RMQ>:
mov    %ecx,%r8d
mov    %edx,%ecx
test   %edx,%edx
js     1142 <RMQ+0x22>
mov    %esi,%edx
cmp    %r8d,%esi
jle    1142 <RMQ+0x22>
cmp    %r8d,%ecx
jg     1142 <RMQ+0x22>
add    $0xffffffff,%edx
xor    %esi,%esi
xor    %r9d,%r9d
jmp    1040 <RMQUtil@plt>
push   %rax
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Invalid input\0A\00"
define i32 @RMQ(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = sub nsw i32 %14, 1
%16 = icmp sgt i32 %13, %15
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17, %12, %4
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %30
23: ; preds = %17
%24 = load i32*, i32** %6
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = call i32 @RMQUtil(i32* %24, i32 0, i32 %26, i32 %27, i32 %28, i32 0)
store i32 %29, i32* %5
br label %30
30: ; preds = %23, %21
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@str = [14 x i8] c"Invalid input\00"
define i32 @RMQ(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %10, label %6
6: ; preds = %4
%7 = icmp sle i32 %1, %3
%8 = icmp sgt i32 %2, %3
%9 = or i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %15
12: ; preds = %6
%13 = add nsw i32 %1, -1
%14 = tail call i32 @RMQUtil(i32* %0, i32 0, i32 %13, i32 %2, i32 %3, i32 0)
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ -1, %10 ], [ %14, %12 ]
ret i32 %16
}