#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 */
long atol(char *);
int /*<<< orphan*/ beep();
int /*<<< orphan*/ clrtoeol();
int /*<<< orphan*/ echo();
int /*<<< orphan*/ move(int, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
scalar_t__ numeric(char *);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ scanw(char *, char *);
int /*<<< orphan*/ sleep(int);
long getnumval(char *ask, long valuenow, int statline) {
  char numval[16];
  long retval;
  echo();
  move(statline, 0);
  clrtoeol();
  printw(ask, valuenow);
  numval[0] = 0;
  scanw("%15s", numval);
  move(statline, 0);
  noecho();
  if (numval[0]) {
    if (numeric(numval)) {
      retval = atol(numval);
    } else {
      beep();
      clrtoeol();
      printw("Value not numeric (current value kept)!");
      refresh();
      sleep(2);
      retval = valuenow;
    }
  } else {
    retval = valuenow;
  }
  return retval;
}


x86 assembly (clang, -O0):
<getnumval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1030 <echo@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   10d0 <move@plt>
mov    $0x0,%al
call   1090 <clrtoeol@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <printw@plt>
movb   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   10b0 <scanw@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   10d0 <move@plt>
mov    $0x0,%al
call   10a0 <noecho@plt>
cmpb   $0x0,-0x30(%rbp)
je     1278 <getnumval+0xc8>
lea    -0x30(%rbp),%rdi
call   1040 <numeric@plt>
cmp    $0x0,%rax
je     123e <getnumval+0x8e>
lea    -0x30(%rbp),%rdi
call   1080 <atol@plt>
mov    %rax,-0x38(%rbp)
jmp    1273 <getnumval+0xc3>
mov    $0x0,%al
call   1050 <beep@plt>
mov    $0x0,%al
call   1090 <clrtoeol@plt>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printw@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x2,%edi
call   10c0 <sleep@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1280 <getnumval+0xd0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnumval>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <echo@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   10d0 <move@plt>
xor    %eax,%eax
call   1090 <clrtoeol@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printw@plt>
movb   $0x0,(%rsp)
lea    0xe11(%rip),%rdi
mov    %rsp,%rsi
call   10b0 <scanw@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   10d0 <move@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
cmpb   $0x0,(%rsp)
je     1254 <getnumval+0xa4>
mov    %rsp,%rdi
call   1040 <numeric@plt>
test   %rax,%rax
je     1227 <getnumval+0x77>
mov    %rsp,%rdi
call   1080 <atol@plt>
mov    %rax,%r14
jmp    1254 <getnumval+0xa4>
xor    %eax,%eax
call   1050 <beep@plt>
xor    %eax,%eax
call   1090 <clrtoeol@plt>
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1060 <printw@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
mov    $0x2,%edi
call   10c0 <sleep@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%15s\00"
@.str.1 = [40 x i8] c"Value not numeric (current value kept)!\00"
define i64 @getnumval(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca [16 x i8]
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%9 = call i32 (...) @echo()
%10 = load i32, i32* %6
%11 = call i32 @move(i32 %10, i32 0)
%12 = call i32 (...) @clrtoeol()
%13 = load i8*, i8** %4
%14 = load i64, i64* %5
%15 = call i32 (i8*, ...) @printw(i8* %13, i64 %14)
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
store i8 0, i8* %16
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%18 = call i32 @scanw(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %6
%20 = call i32 @move(i32 %19, i32 0)
%21 = call i32 (...) @noecho()
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %3
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%27 = call i64 @numeric(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%31 = call i64 @atol(i8* %30)
store i64 %31, i64* %8
br label %39
32: ; preds = %25
%33 = call i32 (...) @beep()
%34 = call i32 (...) @clrtoeol()
%35 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 (...) @refresh()
%37 = call i32 @sleep(i32 2)
%38 = load i64, i64* %5
store i64 %38, i64* %8
br label %39
39: ; preds = %32, %29
br label %42
40: ; preds = %3
%41 = load i64, i64* %5
store i64 %41, i64* %8
br label %42
42: ; preds = %40, %39
%43 = load i64, i64* %8
ret i64 %43
}

LLVM IR (-O2):
@.str = [5 x i8] c"%15s\00"
@.str.1 = [40 x i8] c"Value not numeric (current value kept)!\00"
define i64 @getnumval(i8* %0, i64 %1, i32 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (...) @echo()
%7 = tail call i32 @move(i32 %2, i32 0)
%8 = tail call i32 (...) @clrtoeol()
%9 = tail call i32 (i8*, ...) @printw(i8* %0, i64 %1)
store i8 0, i8* %5
%10 = call i32 @scanw(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5)
%11 = call i32 @move(i32 %2, i32 0)
%12 = call i32 (...) @noecho()
%13 = load i8, i8* %5
%14 = icmp eq i8 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %3
%16 = call i64 @numeric(i8* %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i64 @atol(i8* %5)
br label %26
20: ; preds = %15
%21 = call i32 (...) @beep()
%22 = call i32 (...) @clrtoeol()
%23 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (...) @refresh()
%25 = call i32 @sleep(i32 2)
br label %26
26: ; preds = %3, %18, %20
%27 = phi i64 [ %19, %18 ], [ %1, %20 ], [ %1, %3 ]
ret i64 %27
}