#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 INT_MAX;
int INT_MIN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int input(int arr[], int min_range[], int max_range[]) {
  int len, i;
  printf("Enter length: ");
  if (scanf("%d", &len) != 1) {
    printf("Invalid input!\n");
    exit(0);
  }
  for (i = 0; i < len; i++) {
    printf("Enter min and max of %d number: ", i + 1);
    if (scanf("%d", min_range + i) != 1 || min_range[i] < INT_MIN ||
        min_range[i] > INT_MAX) {
      printf("Invalid input!\n");
      exit(0);
    }
    if (scanf("%d", max_range + i) != 1 || max_range[i] < INT_MIN ||
        max_range[i] > INT_MAX) {
      printf("Invalid input!\n");
      exit(0);
    }
  }
  for (i = 0; i < len; i++) {
    printf("Enter %d number :", i + 1);
    if (scanf("%d", arr + i) != 1 || arr[i] < min_range[i] ||
        arr[i] > max_range[i]) {
      printf("Invalid input!\n");
      exit(0);
    }
  }
  return len;
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     1180 <input+0x50>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1294 <input+0x164>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe52(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11ff <input+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%eax
jl     11ff <input+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
jle    1214 <input+0xe4>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde5(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    126c <input+0x13c>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
jl     126c <input+0x13c>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2d84(%rip),%rcx
cmp    (%rcx),%eax
jle    1281 <input+0x151>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1286 <input+0x156>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1187 <input+0x57>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    133f <input+0x20f>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd3e(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1317 <input+0x1e7>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jl     1317 <input+0x1e7>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    132c <input+0x1fc>
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1331 <input+0x201>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    129b <input+0x16b>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,0x20(%rsp)
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1214 <input+0xd4>
lea    0xe87(%rip),%rbx
mov    0x2e51(%rip),%r15
mov    0x2e52(%rip),%r12
mov    %rbp,0x18(%rsp)
mov    %r14,0x10(%rsp)
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq 0xc(%rsp),%rax
cmp    %rax,%r13
jge    1227 <input+0xe7>
lea    0x1(%r13),%esi
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1214 <input+0xd4>
mov    0x0(%rbp),%eax
cmp    (%r15),%eax
jl     1214 <input+0xd4>
cmp    (%r12),%eax
jg     1214 <input+0xd4>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1214 <input+0xd4>
mov    (%r14),%eax
cmp    (%r15),%eax
jl     1214 <input+0xd4>
add    $0x4,%r14
add    $0x4,%rbp
add    $0x1,%r13
cmp    (%r12),%eax
jle    11b0 <input+0x70>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>
test   %eax,%eax
jle    128a <input+0x14a>
lea    0xe01(%rip),%r14
lea    0xdd6(%rip),%r13
xor    %ebx,%ebx
mov    0x10(%rsp),%r12
lea    0x1(%rbx),%r15
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%rax
lea    (%rax,%rbx,4),%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1214 <input+0xd4>
mov    0x0(%rbp),%eax
mov    0x18(%rsp),%rcx
cmp    (%rcx,%rbx,4),%eax
jl     1214 <input+0xd4>
cmp    (%r12,%rbx,4),%eax
jg     1214 <input+0xd4>
movslq 0xc(%rsp),%rax
mov    %r15,%rbx
cmp    %rax,%r15
jl     1240 <input+0x100>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Invalid input!\0A\00"
@.str.3 = [33 x i8] c"Enter min and max of %d number: \00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.4 = [18 x i8] c"Enter %d number :\00"
define i32 @input(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** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %3
store i32 0, i32* %8
br label %16
16: ; preds = %76, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %79
20: ; preds = %16
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %5
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
%29 = icmp ne i32 %28, 1
br i1 %29, label %46, label %30
30: ; preds = %20
%31 = load i32*, i32** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* @INT_MIN
%37 = icmp slt i32 %35, %36
br i1 %37, label %46, label %38
38: ; preds = %30
%39 = load i32*, i32** %5
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* @INT_MAX
%45 = icmp sgt i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %38, %30, %20
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %38
%50 = load i32*, i32** %6
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %53)
%55 = icmp ne i32 %54, 1
br i1 %55, label %72, label %56
56: ; preds = %49
%57 = load i32*, i32** %6
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* @INT_MIN
%63 = icmp slt i32 %61, %62
br i1 %63, label %72, label %64
64: ; preds = %56
%65 = load i32*, i32** %6
%66 = load i32, i32* %8
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = load i32, i32* @INT_MAX
%71 = icmp sgt i32 %69, %70
br i1 %71, label %72, label %75
72: ; preds = %64, %56, %49
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %64
br label %76
76: ; preds = %75
%77 = load i32, i32* %8
%78 = add nsw i32 %77, 1
store i32 %78, i32* %8
br label %16
79: ; preds = %16
store i32 0, i32* %8
br label %80
80: ; preds = %122, %79
%81 = load i32, i32* %8
%82 = load i32, i32* %7
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %125
84: ; preds = %80
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %86)
%88 = load i32*, i32** %4
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
%92 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %91)
%93 = icmp ne i32 %92, 1
br i1 %93, label %118, label %94
94: ; preds = %84
%95 = load i32*, i32** %4
%96 = load i32, i32* %8
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %95, i64 %97
%99 = load i32, i32* %98
%100 = load i32*, i32** %5
%101 = load i32, i32* %8
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %100, i64 %102
%104 = load i32, i32* %103
%105 = icmp slt i32 %99, %104
br i1 %105, label %118, label %106
106: ; preds = %94
%107 = load i32*, i32** %4
%108 = load i32, i32* %8
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i32, i32* %107, i64 %109
%111 = load i32, i32* %110
%112 = load i32*, i32** %6
%113 = load i32, i32* %8
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %112, i64 %114
%116 = load i32, i32* %115
%117 = icmp sgt i32 %111, %116
br i1 %117, label %118, label %121
118: ; preds = %106, %94, %84
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%120 = call i32 @exit(i32 0)
unreachable
121: ; preds = %106
br label %122
122: ; preds = %121
%123 = load i32, i32* %8
%124 = add nsw i32 %123, 1
store i32 %124, i32* %8
br label %80
125: ; preds = %80
%126 = load i32, i32* %7
ret i32 %126
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter length: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [33 x i8] c"Enter min and max of %d number: \00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.4 = [18 x i8] c"Enter %d number :\00"
@str.7 = [15 x i8] c"Invalid input!\00"
define i32 @input(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = icmp eq i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %3, %40
%13 = phi i64 [ %20, %40 ], [ 0, %3 ]
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = icmp sgt i32 %14, 0
br i1 %18, label %50, label %74
19: ; preds = %12
%20 = add nuw nsw i64 %13, 1
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i32, i32* %1, i64 %13
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i32, i32* %23
%28 = load i32, i32* @INT_MIN
%29 = icmp slt i32 %27, %28
%30 = load i32, i32* @INT_MAX
%31 = icmp sgt i32 %27, %30
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %33, label %36
33: ; preds = %26, %19
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %26
%37 = getelementptr inbounds i32, i32* %2, i64 %13
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %37)
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load i32, i32* %37
%42 = load i32, i32* @INT_MIN
%43 = icmp slt i32 %41, %42
%44 = load i32, i32* @INT_MAX
%45 = icmp sgt i32 %41, %44
%46 = select i1 %43, i1 true, i1 %45
br i1 %46, label %47, label %12
47: ; preds = %40, %36
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %17, %67
%51 = phi i64 [ %52, %67 ], [ 0, %17 ]
%52 = add nuw nsw i64 %51, 1
%53 = trunc i64 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds i32, i32* %0, i64 %51
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %55)
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %71
58: ; preds = %50
%59 = load i32, i32* %55
%60 = getelementptr inbounds i32, i32* %1, i64 %51
%61 = load i32, i32* %60
%62 = icmp slt i32 %59, %61
br i1 %62, label %71, label %63
63: ; preds = %58
%64 = getelementptr inbounds i32, i32* %2, i64 %51
%65 = load i32, i32* %64
%66 = icmp sgt i32 %59, %65
br i1 %66, label %71, label %67
67: ; preds = %63
%68 = load i32, i32* %4
%69 = sext i32 %68 to i64
%70 = icmp slt i64 %52, %69
br i1 %70, label %50, label %74
71: ; preds = %63, %58, %50
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%73 = call i32 @exit(i32 0)
unreachable
74: ; preds = %67, %17
%75 = phi i32 [ %14, %17 ], [ %68, %67 ]
ret i32 %75
}