#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 /*<<< orphan*/ build(int *, int *, int /*<<< orphan*/, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int query(int *, int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int size;
  printf("Enter the size of the array: ");
  scanf("%d", &size);
  int array[size];
  int *segTree = (int *)malloc(sizeof(4 * size));
  printf("Enter the elements.\n");
  for (int i = 0; i < size; i++) {
    scanf("%d", &array[i]);
  }
  build(array, segTree, 0, size - 1, 1);
  int start, end;
  printf("Enter the range of the query: ");
  scanf("%d %d", &start, &end);
  int result = query(segTree, 0, size - 1, start - 1, end - 1, 1);
  printf("Minimum value in index range %d to %d is: %d\n", start, end, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x39(%rbp)
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1204 <main+0xb4>
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cd <main+0x7d>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
xor    %edx,%edx
mov    $0x1,%r8d
call   1030 <build@plt>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x2c(%rbp),%r8d
sub    $0x1,%r8d
xor    %esi,%esi
mov    $0x1,%r9d
call   1050 <query@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %rsp,%rbx
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    1202 <main+0xa2>
mov    %rbx,-0x40(%rbp)
lea    0xe69(%rip),%r12
mov    %r15,%rbx
xor    %r13d,%r13d
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rcx
add    $0x4,%rbx
cmp    %rcx,%r13
jl     11e0 <main+0x80>
mov    -0x40(%rbp),%rbx
add    $0xffffffff,%ecx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0x1,%r8d
call   1040 <build@plt>
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe10(%rip),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    -0x2c(%rbp),%edx
add    $0xffffffff,%edx
mov    -0x34(%rbp),%ecx
add    $0xffffffff,%ecx
mov    -0x30(%rbp),%r8d
add    $0xffffffff,%r8d
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%r9d
call   1060 <query@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xdd6(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter the elements.\0A\00"
@.str.3 = [31 x i8] c"Enter the range of the query: \00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [46 x i8] c"Minimum value in index range %d to %d is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %3
%15 = alloca i32, i64 %13
store i64 %13, i64* %4
%16 = call i64 @malloc(i32 4)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %19
19: ; preds = %28, %0
%20 = load i32, i32* %6
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %15, i64 %25
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %23
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %19
31: ; preds = %19
%32 = load i32*, i32** %5
%33 = load i32, i32* %2
%34 = sub nsw i32 %33, 1
%35 = call i32 @build(i32* %15, i32* %32, i32 0, i32 %34, i32 1)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8)
%38 = load i32*, i32** %5
%39 = load i32, i32* %2
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %7
%42 = sub nsw i32 %41, 1
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 1
%45 = call i32 @query(i32* %38, i32 0, i32 %40, i32 %42, i32 %44, i32 1)
store i32 %45, i32* %9
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %46, i32 %47, i32 %48)
store i32 0, i32* %1
%50 = load i8*, i8** %3
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [30 x i8] c"Enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"Enter the range of the query: \00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [46 x i8] c"Minimum value in index range %d to %d is: %d\0A\00"
@str = [20 x i8] c"Enter the elements.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = call i64 @malloc(i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %34, label %16
16: ; preds = %34, %0
%17 = phi i32 [ %14, %0 ], [ %39, %34 ]
%18 = add nsw i32 %17, -1
%19 = call i32 @build(i32* %10, i32* %12, i32 0, i32 %18, i32 1)
%20 = bitcast i32* %2 to i8*
%21 = bitcast i32* %3 to i8*
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%24 = load i32, i32* %1
%25 = add nsw i32 %24, -1
%26 = load i32, i32* %2
%27 = add nsw i32 %26, -1
%28 = load i32, i32* %3
%29 = add nsw i32 %28, -1
%30 = call i32 @query(i32* %12, i32 0, i32 %25, i32 %27, i32 %29, i32 1)
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 %32, i32 %30)
ret i32 0
34: ; preds = %0, %34
%35 = phi i64 [ %38, %34 ], [ 0, %0 ]
%36 = getelementptr inbounds i32, i32* %10, i64 %35
%37 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %36)
%38 = add nuw nsw i64 %35, 1
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %38, %40
br i1 %41, label %34, label %16
}