int gnum(pr, high, low, msg)
char *pr;
int high;
int low;
char **msg;
{
  int i;
  char sx[8];
  do {
    memset(sx, 0, 8);
    i = readdefault(pr, sx, 7, "");
    if (i == 0)
      return (0);
    i = atoi(sx);
    if (toupper(*sx) == 'L') {
      glist(msg);
      i = -1;
    } else if ((i < low) || (i > high)) {
      printf("%s is out of range\n", sx);
      i = -1;
    }
  } while (i == -1);
  return (i);
}


x86 assembly (clang, -O0):
<gnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x7,%edx
lea    0xe79(%rip),%rcx
mov    $0x0,%al
call   1030 <readdefault@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11ba <gnum+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    123c <gnum+0xdc>
lea    -0x2c(%rbp),%rdi
mov    $0x0,%al
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
movsbl -0x2c(%rbp),%edi
call   1040 <toupper@plt>
cmp    $0x4c,%eax
jne    11f1 <gnum+0x91>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1080 <glist@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    1227 <gnum+0xc7>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     1209 <gnum+0xa9>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1222 <gnum+0xc2>
lea    -0x2c(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    1227 <gnum+0xc7>
jmp    122c <gnum+0xcc>
cmpl   $0xffffffff,-0x24(%rbp)
je     1176 <gnum+0x16>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,0xc(%rsp)
mov    %rdi,%rbx
lea    0xea1(%rip),%r13
lea    0x10(%rsp),%rbp
jmp    1196 <gnum+0x46>
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <glist@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%r14d
jne    11f6 <gnum+0xa6>
movq   $0x0,0x10(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x7,%edx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <readdefault@plt>
test   %eax,%eax
je     11f3 <gnum+0xa3>
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <atoi@plt>
mov    %eax,%r14d
movsbl 0x10(%rsp),%edi
call   1040 <toupper@plt>
cmp    $0x4c,%eax
je     1180 <gnum+0x30>
cmp    %r12d,%r14d
jl     11e0 <gnum+0x90>
cmp    0xc(%rsp),%r14d
jle    1190 <gnum+0x40>
lea    0xe19(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118a <gnum+0x3a>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [20 x i8] c"%s is out of range\0A\00"
define i32 @gnum(i8* %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca [8 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
br label %12
12: ; preds = %44, %4
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%16 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @readdefault to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %14, i8* %15, i32 7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 0, i32* %5
br label %49
20: ; preds = %12
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %21)
store i32 %22, i32* %10
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 @toupper(i32 %25)
%27 = icmp eq i32 %26, 76
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = load i8**, i8*** %9
%30 = call i32 (i8**, ...) bitcast (i32 (...)* @glist to i32 (i8**, ...)*)(i8** %29)
store i32 -1, i32* %10
br label %43
31: ; preds = %20
%32 = load i32, i32* %10
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35, %31
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %40)
store i32 -1, i32* %10
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43
%45 = load i32, i32* %10
%46 = icmp eq i32 %45, -1
br i1 %46, label %12, label %47
47: ; preds = %44
%48 = load i32, i32* %10
store i32 %48, i32* %5
br label %49
49: ; preds = %47, %19
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [20 x i8] c"%s is out of range\0A\00"
define i32 @gnum(i8* %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
br label %7
7: ; preds = %24, %4
store i64 0, i64* %5
%8 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @readdefault to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %0, i8* %6, i32 7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %7
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %6)
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
%14 = call i32 @toupper(i32 %13)
%15 = icmp eq i32 %14, 76
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (i8**, ...) bitcast (i32 (...)* @glist to i32 (i8**, ...)*)(i8** %3)
br label %24
18: ; preds = %10
%19 = icmp slt i32 %11, %2
%20 = icmp sgt i32 %11, %1
%21 = or i1 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64* %5)
br label %24
24: ; preds = %18, %16, %22
%25 = phi i32 [ -1, %16 ], [ -1, %22 ], [ %11, %18 ]
%26 = icmp eq i32 %25, -1
br i1 %26, label %7, label %27
27: ; preds = %24, %7
%28 = phi i32 [ 0, %7 ], [ %25, %24 ]
ret i32 %28
}