#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 atoi(char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ getstring(char *, int, char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ stdout;
void getnums(int *nm) {
  char str[10];
  unsigned short int i = 0;
  getstring(str, 10, 'n');
  for (; str[i]; i++) {
    if (!isdigit(str[i])) {
      fputs("Not a number. Enter again: ", stdout);
      getstring(str, 10, 'n');
      i = 0;
    }
  }
  *nm = atoi(str);
}


x86 assembly (clang, -O0):
<getnums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0x14(%rbp)
lea    -0x12(%rbp),%rdi
mov    $0xa,%esi
mov    $0x6e,%edx
call   1030 <getstring@plt>
movzwl -0x14(%rbp),%eax
cmpb   $0x0,-0x12(%rbp,%rax,1)
je     11cf <getnums+0x8f>
movzwl -0x14(%rbp),%eax
movsbl -0x12(%rbp,%rax,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    11b9 <getnums+0x79>
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    0xe65(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x12(%rbp),%rdi
mov    $0xa,%esi
mov    $0x6e,%edx
call   1030 <getstring@plt>
movw   $0x0,-0x14(%rbp)
jmp    11be <getnums+0x7e>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1165 <getnums+0x25>
lea    -0x12(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnums>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x6(%rsp),%rdi
mov    $0xa,%esi
mov    $0x6e,%edx
call   1030 <getstring@plt>
mov    0x6(%rsp),%al
test   %al,%al
je     11cd <getnums+0x8d>
xor    %ebx,%ebx
mov    0x2e6b(%rip),%r12
lea    0xe84(%rip),%r15
lea    0x6(%rsp),%r13
jmp    119f <getnums+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
movzwl %bx,%eax
movzbl 0x6(%rsp,%rax,1),%eax
test   %al,%al
je     11cd <getnums+0x8d>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1190 <getnums+0x50>
mov    (%r12),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
mov    %r13,%rdi
mov    $0xa,%esi
mov    $0x6e,%edx
call   1030 <getstring@plt>
xor    %ebx,%ebx
jmp    1190 <getnums+0x50>
lea    0x6(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Not a number. Enter again: \00"
@stdout = global i32 0
define void @getnums(i32* %0) {
%2 = alloca i32*
%3 = alloca [10 x i8]
%4 = alloca i16
store i32* %0, i32** %2
store i16 0, i16* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @getstring(i8* %5, i32 10, i8 signext 110)
br label %7
7: ; preds = %26, %1
%8 = load i16, i16* %4
%9 = zext i16 %8 to i64
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %7
%14 = load i16, i16* %4
%15 = zext i16 %14 to i64
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @isdigit(i8 signext %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %13
%21 = load i32, i32* @stdout
%22 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%24 = call i32 @getstring(i8* %23, i32 10, i8 signext 110)
store i16 0, i16* %4
br label %25
25: ; preds = %20, %13
br label %26
26: ; preds = %25
%27 = load i16, i16* %4
%28 = add i16 %27, 1
store i16 %28, i16* %4
br label %7
29: ; preds = %7
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%31 = call i32 @atoi(i8* %30)
%32 = load i32*, i32** %2
store i32 %31, i32* %32
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Not a number. Enter again: \00"
@stdout = global i32 0
define void @getnums(i32* nocapture writeonly %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @getstring(i8* %3, i32 10, i8 signext 110)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %1, %16
%8 = phi i8 [ %21, %16 ], [ %5, %1 ]
%9 = phi i16 [ %18, %16 ], [ 0, %1 ]
%10 = call i32 @isdigit(i8 signext %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @getstring(i8* %3, i32 10, i8 signext 110)
br label %16
16: ; preds = %7, %12
%17 = phi i16 [ %9, %7 ], [ 0, %12 ]
%18 = add i16 %17, 1
%19 = zext i16 %18 to i64
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %7
23: ; preds = %16, %1
%24 = call i32 @atoi(i8* %3)
store i32 %24, i32* %0
ret void
}