#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int stu_id;
  int sems;
  int numco;
  int co_id;
  printf("Enter student ID: ");
  scanf("%d", &stu_id);
  if (stu_id > 1000 && stu_id <= 1005) {
    printf("\nEnter current semester: ");
    scanf("%d", &sems);
    if (sems == 5) {
      numco = 0;
      printf("\nCurrent Number of Courses: %d\n", numco);
      if (numco == 0) {
        while (numco < 2) {
          printf("\nEnter Course ID: ");
          scanf("%d", &co_id);
          if (co_id > 5000 && co_id <= 5005) {
            printf("\nEx: Course ID %d is allocated with ID %d\n", co_id,
                   stu_id);
            numco++;
            printf("\nCurrent number of courses: %d\n", numco);
          } else {
            printf("\nError! Course ID invalid!");
            printf("\nExiting Program!\n");
          }
        }
      } else {
        printf("\nError! Your courses must be zero to proceed");
        printf("\nExiting Program!\n");
      }
    } else {
      printf("\nError! Your current semester is not applicable\n");
      printf("\nExiting Program!\n");
    }
  } else {
    printf("\nError! Your Student ID is not applicable\n");
    printf("\nExiting Program!\n");
  }
  printf("\nThank you for using this program!");
  printf("\nHave a nice day!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3e8,-0x8(%rbp)
jle    1293 <main+0x173>
cmpl   $0x3ed,-0x8(%rbp)
jg     1293 <main+0x173>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x5,-0xc(%rbp)
jne    1272 <main+0x152>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1251 <main+0x131>
jmp    11b6 <main+0x96>
cmpl   $0x2,-0x10(%rbp)
jge    124c <main+0x12c>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1388,-0x14(%rbp)
jle    122b <main+0x10b>
cmpl   $0x138d,-0x14(%rbp)
jg     122b <main+0x10b>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x127>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b6 <main+0x96>
jmp    126d <main+0x14d>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128e <main+0x16e>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12af <main+0x18f>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xfffffc17,%eax
add    0xc(%rsp),%eax
cmp    $0x4,%eax
ja     123b <main+0x10b>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x5,0x14(%rsp)
jne    1244 <main+0x114>
lea    0xe90(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%r14
lea    0xe5c(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xeeb(%rip),%rbp
lea    0xf8e(%rip),%r12
xor    %r13d,%r13d
jmp    11e8 <main+0xb8>
nop
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
cmp    $0x2,%r13d
jge    125c <main+0x12c>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%esi
lea    -0x1389(%rsi),%eax
cmp    $0x4,%eax
ja     11d0 <main+0xa0>
mov    0xc(%rsp),%edx
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
lea    0xe65(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r13d
jl     11e8 <main+0xb8>
jmp    125c <main+0x12c>
lea    0xeaa(%rip),%rdi
jmp    124b <main+0x11b>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter student ID: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AEnter current semester: \00"
@.str.3 = [32 x i8] c"\0ACurrent Number of Courses: %d\0A\00"
@.str.4 = [19 x i8] c"\0AEnter Course ID: \00"
@.str.5 = [43 x i8] c"\0AEx: Course ID %d is allocated with ID %d\0A\00"
@.str.6 = [32 x i8] c"\0ACurrent number of courses: %d\0A\00"
@.str.7 = [27 x i8] c"\0AError! Course ID invalid!\00"
@.str.8 = [19 x i8] c"\0AExiting Program!\0A\00"
@.str.9 = [45 x i8] c"\0AError! Your courses must be zero to proceed\00"
@.str.10 = [49 x i8] c"\0AError! Your current semester is not applicable\0A\00"
@.str.11 = [43 x i8] c"\0AError! Your Student ID is not applicable\0A\00"
@.str.12 = [35 x i8] c"\0AThank you for using this program!\00"
@.str.13 = [19 x i8] c"\0AHave a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 1000
br i1 %9, label %10, label %56
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp sle i32 %11, 1005
br i1 %12, label %13, label %56
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 5
br i1 %17, label %18, label %52
18: ; preds = %13
store i32 0, i32* %4
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %48
23: ; preds = %18
br label %24
24: ; preds = %46, %23
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 2
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%30 = load i32, i32* %5
%31 = icmp sgt i32 %30, 5000
br i1 %31, label %32, label %43
32: ; preds = %27
%33 = load i32, i32* %5
%34 = icmp sle i32 %33, 5005
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i32, i32* %5
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %37)
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %41)
br label %46
43: ; preds = %32, %27
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %43, %35
br label %24
47: ; preds = %24
br label %51
48: ; preds = %18
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %51
51: ; preds = %48, %47
br label %55
52: ; preds = %13
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %55
55: ; preds = %52, %51
br label %59
56: ; preds = %10, %0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %56, %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter student ID: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AEnter current semester: \00"
@.str.3 = [32 x i8] c"\0ACurrent Number of Courses: %d\0A\00"
@.str.4 = [19 x i8] c"\0AEnter Course ID: \00"
@.str.5 = [43 x i8] c"\0AEx: Course ID %d is allocated with ID %d\0A\00"
@.str.6 = [32 x i8] c"\0ACurrent number of courses: %d\0A\00"
@.str.7 = [27 x i8] c"\0AError! Course ID invalid!\00"
@.str.12 = [35 x i8] c"\0AThank you for using this program!\00"
@str = [42 x i8] c"\0AError! Your Student ID is not applicable\00"
@str.15 = [18 x i8] c"\0AHave a nice day!\00"
@str.16 = [48 x i8] c"\0AError! Your current semester is not applicable\00"
@str.18 = [18 x i8] c"\0AExiting Program!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -1001
%11 = icmp ult i32 %10, 5
br i1 %11, label %12, label %37
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 5
br i1 %16, label %17, label %37
17: ; preds = %12
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %19
19: ; preds = %17, %34
%20 = phi i32 [ 0, %17 ], [ %35, %34 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = add i32 %23, -5001
%25 = icmp ult i32 %24, 5
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = load i32, i32* %1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %27)
%29 = add nsw i32 %20, 1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %29)
br label %34
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.18, i64 0, i64 0))
br label %34
34: ; preds = %31, %26
%35 = phi i32 [ %29, %26 ], [ %20, %31 ]
%36 = icmp slt i32 %35, 2
br i1 %36, label %19, label %42
37: ; preds = %0, %12
%38 = phi i8* [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.16, i64 0, i64 0), %12 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0), %0 ]
%39 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.18, i64 0, i64 0), %12 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.18, i64 0, i64 0), %0 ]
%40 = call i32 @puts(i8* dereferenceable(1) %38)
%41 = call i32 @puts(i8* dereferenceable(1) %39)
br label %42
42: ; preds = %34, %37
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0))
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.15, i64 0, i64 0))
ret i32 0
}