#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int /*<<< orphan*/ stdin;
int numStudents(void) {
  int num, result;
  do {
    printf("Enter the number of students>");
    fflush(stdin);
    result = scanf("%d", &num);
    if ((result != 1) || (num <= 0) || (num >= 10)) {
      printf("Invalid input, must be a positive integer from 1 to 10.\n");
    }
  } while ((result != 1) || (num <= 0) || (num >= 10));
  return (num);
}


x86 assembly (clang, -O0):
<numStudents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xec5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1183 <numStudents+0x53>
cmpl   $0x0,-0x4(%rbp)
jle    1183 <numStudents+0x53>
cmpl   $0xa,-0x4(%rbp)
jl     118f <numStudents+0x5f>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <numStudents+0x64>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jne    11bc <numStudents+0x8c>
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jle    11bc <numStudents+0x8c>
cmpl   $0xa,-0x4(%rbp)
setge  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1138 <numStudents+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numStudents>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%r14
mov    0x2e8f(%rip),%r13
lea    0xebe(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xeb5(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    11b0 <numStudents+0x70>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11b0 <numStudents+0x70>
cmp    $0xa,%eax
jge    11b0 <numStudents+0x70>
cmp    $0x1,%ebp
jne    1170 <numStudents+0x30>
test   %eax,%eax
jle    1170 <numStudents+0x30>
cmp    $0x9,%eax
jg     1170 <numStudents+0x30>
jmp    11c3 <numStudents+0x83>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%ebp
je     11a5 <numStudents+0x65>
jmp    1170 <numStudents+0x30>
add    $0x8,%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 @numStudents() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %28, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 1
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = load i32, i32* %1
%12 = icmp sle i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp sge i32 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %13, %10, %3
%17 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
br label %19
19: ; preds = %18
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 1
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = load i32, i32* %1
%24 = icmp sle i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %1
%27 = icmp sge i32 %26, 10
br label %28
28: ; preds = %25, %22, %19
%29 = phi i1 [ true, %22 ], [ true, %19 ], [ %27, %25 ]
br i1 %29, label %3, label %30
30: ; preds = %28
%31 = load i32, i32* %1
ret i32 %31
}

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 @numStudents() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %17, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = icmp ne i32 %7, 1
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
%11 = select i1 %8, i1 true, i1 %10
%12 = icmp sgt i32 %9, 9
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%16 = load i32, i32* %1
br label %17
17: ; preds = %14, %3
%18 = phi i32 [ %16, %14 ], [ %9, %3 ]
%19 = icmp slt i32 %18, 1
%20 = select i1 %8, i1 true, i1 %19
%21 = icmp sgt i32 %18, 9
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %3, label %23
23: ; preds = %17
ret i32 %18
}