#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*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int input_n(int min, int max) {
  int n;
  if (min > max) {
    int temp;
    temp = min;
    min = max;
    max = temp;
  }
  do {
    printf("Inserire un numero (%d,%d): ", min, max);
    scanf("%d", &n);
  } while ((n < min) || (n > max));
  return n;
}


x86 assembly (clang, -O0):
<input_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    114c <input_n+0x2c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <input_n+0x31>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0x11(%rbp)
jl     1190 <input_n+0x70>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1151 <input_n+0x31>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_n>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
cmp    %esi,%edi
mov    %esi,%ebp
cmovg  %edi,%ebp
cmovg  %esi,%ebx
lea    0xec1(%rip),%r14
lea    0xed7(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jl     1150 <input_n+0x30>
cmp    %ebp,%eax
jg     1150 <input_n+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [29 x i8] c"Inserire un numero (%d,%d): \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @input_n(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %0, %1
%6 = select i1 %5, i32 %0, i32 %1
%7 = select i1 %5, i32 %1, i32 %0
br label %8
8: ; preds = %8, %2
%9 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %6)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, %7
%13 = icmp sgt i32 %11, %6
%14 = or i1 %12, %13
br i1 %14, label %8, label %15
15: ; preds = %8
ret i32 %11
}