#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int check_node(char *r) {
  int i, node, n;
  do {
    for (i = 0; r[i] != '\0'; ++i) {
      if (r[i] < '0' || r[i] > '9') {
        puts(r);
        if (r[0] == '-' && r[1] == '1' && r[2] == '\0')
          break;
        fprintf(stderr, "\nError! The nodes can be only positive integers!\n");
        printf("Give the node again or -1 to terminate: ");
        fgets(r, 10, stdin);
        n = strlen(r);
        r[n - 1] = '\0';
        i = -1;
      }
    }
    node = atoi(r);
    if (node > 10 - 1) {
      printf("Error! the node must be 0 - %d! Try again: ", 10 - 1);
      fgets(r, 10, stdin);
      n = strlen(r);
      r[n - 1] = '\0';
    }
  } while (node > 10 - 1);
  return node;
}


x86 assembly (clang, -O0):
<check_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1263 <check_node+0x103>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     11b2 <check_node+0x52>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1250 <check_node+0xf0>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11f2 <check_node+0x92>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x31,%eax
jne    11f2 <check_node+0x92>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    11f2 <check_node+0x92>
jmp    1263 <check_node+0x103>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2dc8(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0xffffffff,-0xc(%rbp)
jmp    1255 <check_node+0xf5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <check_node+0x13>
mov    -0x8(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x9,-0x10(%rbp)
jle    12c0 <check_node+0x160>
lea    0xddb(%rip),%rdi
mov    $0x9,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d51(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    12c5 <check_node+0x165>
cmpl   $0x9,-0x10(%rbp)
jg     116c <check_node+0xc>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_node>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee6(%rip),%r14
mov    0x2e6c(%rip),%r13
mov    0x2e55(%rip),%rbp
lea    0xe76(%rip),%r15
lea    0xea1(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%cl
test   %cl,%cl
je     1220 <check_node+0xc0>
xor    %eax,%eax
jmp    11f9 <check_node+0x99>
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
mov    %r15,%rsi
call   1070 <fprintf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    $0xffffffff,%eax
cltq
movzbl 0x1(%rbx,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
je     1220 <check_node+0xc0>
add    $0xc6,%cl
cmp    $0xf5,%cl
ja     11ea <check_node+0x8a>
mov    %rbx,%rdi
call   1030 <puts@plt>
cmpb   $0x2d,(%rbx)
jne    11b0 <check_node+0x50>
cmpb   $0x31,0x1(%rbx)
jne    11b0 <check_node+0x50>
cmpb   $0x0,0x2(%rbx)
jne    11b0 <check_node+0x50>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <atoi@plt>
cmp    $0xa,%eax
jl     1261 <check_node+0x101>
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    11a0 <check_node+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"\0AError! The nodes can be only positive integers!\0A\00"
@.str.1 = [41 x i8] c"Give the node again or -1 to terminate: \00"
@stdin = global i32 0
@.str.2 = [44 x i8] c"Error! the node must be 0 - %d! Try again: \00"
define i32 @check_node(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
br label %6
6: ; preds = %88, %1
store i32 0, i32* %3
br label %7
7: ; preds = %67, %6
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %70
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 48
br i1 %22, label %31, label %23
23: ; preds = %15
%24 = load i8*, i8** %2
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sgt i32 %29, 57
br i1 %30, label %31, label %66
31: ; preds = %23, %15
%32 = load i8*, i8** %2
%33 = call i32 @puts(i8* %32)
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 45
br i1 %38, label %39, label %52
39: ; preds = %31
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 49
br i1 %44, label %45, label %52
45: ; preds = %39
%46 = load i8*, i8** %2
%47 = getelementptr inbounds i8, i8* %46, i64 2
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %45
br label %70
52: ; preds = %45, %39, %31
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%56 = load i8*, i8** %2
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %56, i32 10, i32 %57)
%59 = load i8*, i8** %2
%60 = call i32 @strlen(i8* %59)
store i32 %60, i32* %5
%61 = load i8*, i8** %2
%62 = load i32, i32* %5
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
store i8 0, i8* %65
store i32 -1, i32* %3
br label %66
66: ; preds = %52, %23
br label %67
67: ; preds = %66
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %7
70: ; preds = %51, %7
%71 = load i8*, i8** %2
%72 = call i32 @atoi(i8* %71)
store i32 %72, i32* %4
%73 = load i32, i32* %4
%74 = icmp sgt i32 %73, 9
br i1 %74, label %75, label %87
75: ; preds = %70
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 9)
%77 = load i8*, i8** %2
%78 = load i32, i32* @stdin
%79 = call i32 @fgets(i8* %77, i32 10, i32 %78)
%80 = load i8*, i8** %2
%81 = call i32 @strlen(i8* %80)
store i32 %81, i32* %5
%82 = load i8*, i8** %2
%83 = load i32, i32* %5
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
store i8 0, i8* %86
br label %87
87: ; preds = %75, %70
br label %88
88: ; preds = %87
%89 = load i32, i32* %4
%90 = icmp sgt i32 %89, 9
br i1 %90, label %6, label %91
91: ; preds = %88
%92 = load i32, i32* %4
ret i32 %92
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"\0AError! The nodes can be only positive integers!\0A\00"
@.str.1 = [41 x i8] c"Give the node again or -1 to terminate: \00"
@stdin = global i32 0
@.str.2 = [44 x i8] c"Error! the node must be 0 - %d! Try again: \00"
define i32 @check_node(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 2
%3 = getelementptr inbounds i8, i8* %0, i64 1
br label %4
4: ; preds = %42, %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %39, label %7
7: ; preds = %4, %32
%8 = phi i8 [ %37, %32 ], [ %5, %4 ]
%9 = phi i32 [ %34, %32 ], [ 0, %4 ]
%10 = add i8 %8, -58
%11 = icmp ult i8 %10, -10
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) %0)
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8, i8* %3
%18 = icmp eq i8 %17, 49
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i8, i8* %2
%21 = icmp eq i8 %20, 0
br i1 %21, label %39, label %22
22: ; preds = %19, %16, %12
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = tail call i32 @fgets(i8* %0, i32 10, i32 %26)
%28 = tail call i32 @strlen(i8* %0)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %7, %22
%33 = phi i32 [ -1, %22 ], [ %9, %7 ]
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %0, i64 %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %7
39: ; preds = %32, %19, %4
%40 = tail call i32 @atoi(i8* %0)
%41 = icmp sgt i32 %40, 9
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 9)
%44 = load i32, i32* @stdin
%45 = tail call i32 @fgets(i8* %0, i32 10, i32 %44)
%46 = tail call i32 @strlen(i8* %0)
%47 = add nsw i32 %46, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %0, i64 %48
store i8 0, i8* %49
br label %4
50: ; preds = %39
ret i32 %40
}