#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int numberOfStudents(void) {
  int num, userinput;
  char line[31];
  do {
    printf("Enter the number of students>");
    if (fgets(line, sizeof(line), stdin)) {
      userinput = sscanf(line, "%d", &num);
      if ((userinput != 1) || (num <= 0) || (num > 10)) {
        printf("Invalid input, must be a positive integer from 1 to 10.\n");
      }
    }
  } while ((userinput != 1) || (num <= 0) || (num > 10));
  return (num);
}


x86 assembly (clang, -O0):
<numberOfStudents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    $0x1f,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11ab <numberOfStudents+0x7b>
lea    -0x30(%rbp),%rdi
lea    0xeae(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119a <numberOfStudents+0x6a>
cmpl   $0x0,-0x4(%rbp)
jle    119a <numberOfStudents+0x6a>
cmpl   $0xa,-0x4(%rbp)
jle    11a6 <numberOfStudents+0x76>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    11ab <numberOfStudents+0x7b>
jmp    11b0 <numberOfStudents+0x80>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x31(%rbp)
jne    11d8 <numberOfStudents+0xa8>
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x31(%rbp)
jle    11d8 <numberOfStudents+0xa8>
cmpl   $0xa,-0x4(%rbp)
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1138 <numberOfStudents+0x8>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numberOfStudents>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xeab(%rip),%r14
mov    0x2e8c(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1f,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11c9 <numberOfStudents+0x89>
mov    %rbx,%rdi
lea    0xe86(%rip),%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    11ba <numberOfStudents+0x7a>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11ba <numberOfStudents+0x7a>
mov    $0x1,%r15d
cmp    $0xb,%eax
jl     11c9 <numberOfStudents+0x89>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%r15d
cmp    $0x1,%r15d
jne    1170 <numberOfStudents+0x30>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1170 <numberOfStudents+0x30>
cmp    $0xa,%eax
jg     1170 <numberOfStudents+0x30>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Enter the number of students>\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [57 x i8] c"Invalid input, must be a positive integer from 1 to 10.\0A\00"
define i32 @numberOfStudents() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [31 x i8]
br label %4
4: ; preds = %34, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 31, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %4
%11 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 1
br i1 %14, label %21, label %15
15: ; preds = %10
%16 = load i32, i32* %1
%17 = icmp sle i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %18, %15, %10
%22 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
br label %24
24: ; preds = %23, %4
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 1
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %1
%30 = icmp sle i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %1
%33 = icmp sgt i32 %32, 10
br label %34
34: ; preds = %31, %28, %25
%35 = phi i1 [ true, %28 ], [ true, %25 ], [ %33, %31 ]
br i1 %35, label %4, label %36
36: ; preds = %34
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [30 x i8] c"Enter the number of students>\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@str = [56 x i8] c"Invalid input, must be a positive integer from 1 to 10.\00"
define i32 @numberOfStudents() {
%1 = alloca i32
%2 = alloca [31 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %21, %0
%6 = phi i32 [ undef, %0 ], [ %22, %21 ]
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i64 @fgets(i8* %4, i32 31, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %5
%12 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = icmp ne i32 %12, 1
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 1
%16 = select i1 %13, i1 true, i1 %15
%17 = icmp sgt i32 %14, 10
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %5, %11, %19
%22 = phi i32 [ %12, %19 ], [ 1, %11 ], [ %6, %5 ]
%23 = icmp ne i32 %22, 1
%24 = load i32, i32* %1
%25 = icmp slt i32 %24, 1
%26 = select i1 %23, i1 true, i1 %25
%27 = icmp sgt i32 %24, 10
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %5, label %29
29: ; preds = %21
ret i32 %24
}