#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*/ flush();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int askNumberOfCourses() {
  int valid = 0;
  while (valid == 0) {
    int number = 0;
    printf("\nNumber of courses? ");
    scanf("%d", &number);
    flush();
    if (number > 0) {
      valid = 1;
      return number;
    } else {
      puts("You need to enter a digit greater than one");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<askNumberOfCourses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <askNumberOfCourses+0x70>
movl   $0x0,-0xc(%rbp)
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1030 <flush@plt>
cmpl   $0x0,-0xc(%rbp)
jle    119f <askNumberOfCourses+0x5f>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b7 <askNumberOfCourses+0x77>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
jmp    114f <askNumberOfCourses+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askNumberOfCourses>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea9(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jg     11d2 <askNumberOfCourses+0x92>
lea    0xe95(%rip),%r14
lea    0xe76(%rip),%r15
lea    0xe84(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
movl   $0x0,0x4(%rsp)
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11a0 <askNumberOfCourses+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0ANumber of courses? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"You need to enter a digit greater than one\00"
define i32 @askNumberOfCourses() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %17, %0
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
store i32 0, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = call i32 (...) @flush()
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
store i32 1, i32* %2
%14 = load i32, i32* %3
store i32 %14, i32* %1
br label %19
15: ; preds = %7
%16 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15
br label %4
18: ; preds = %4
store i32 0, i32* %1
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0ANumber of courses? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"You need to enter a digit greater than one\00"
define i32 @askNumberOfCourses() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @flush()
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %0, %8
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = call i32 (...) @flush()
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %8
15: ; preds = %8, %0
%16 = phi i32 [ %6, %0 ], [ %13, %8 ]
ret i32 %16
}