#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 *);
void main() {
  int i = 0;
  int val, total, avg;
  total = 0;
  while (i < 10) {
    printf("Enter a test score (0-100): ");
    scanf("%d", &val);
    while ((val < 0) || (val > 101)) {
      printf("Invalid! Please enter a valid test score (0-100): ");
      scanf("%d", &val);
    }
    total = total + val;
    i += 1;
  }
  avg = total / 10;
  printf("Total: %d\n", total);
  printf("Average: %d", avg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11c1 <main+0xa1>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jl     1177 <main+0x57>
cmpl   $0x65,-0x8(%rbp)
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <main+0x67>
jmp    11aa <main+0x8a>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115e <main+0x3e>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <main+0x16>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%r14
lea    0xf2b(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xed8(%rip),%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    115b <main+0x3b>
nopl   0x0(%rax)
add    %eax,%r13d
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11a0 <main+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x66,%eax
jb     1150 <main+0x30>
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x65,%eax
ja     1180 <main+0x60>
jmp    1150 <main+0x30>
movslq %r13d,%rsi
imul   $0x66666667,%rsi,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter a test score (0-100): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Invalid! Please enter a valid test score (0-100): \00"
@.str.3 = [11 x i8] c"Total: %d\0A\00"
@.str.4 = [12 x i8] c"Average: %d\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %22, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %28
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %19, %8
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 101
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %11
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = add nsw i32 %23, %24
store i32 %25, i32* %3
%26 = load i32, i32* %1
%27 = add nsw i32 %26, 1
store i32 %27, i32* %1
br label %5
28: ; preds = %5
%29 = load i32, i32* %3
%30 = sdiv i32 %29, 10
store i32 %30, i32* %4
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter a test score (0-100): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Invalid! Please enter a valid test score (0-100): \00"
@.str.3 = [11 x i8] c"Total: %d\0A\00"
@.str.4 = [12 x i8] c"Average: %d\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %15
%4 = phi i32 [ 0, %0 ], [ %18, %15 ]
%5 = phi i32 [ 0, %0 ], [ %17, %15 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 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* %1)
%8 = load i32, i32* %1
%9 = icmp ugt i32 %8, 101
br i1 %9, label %10, label %15
10: ; preds = %3, %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp ugt i32 %13, 101
br i1 %14, label %10, label %15
15: ; preds = %10, %3
%16 = phi i32 [ %8, %3 ], [ %13, %10 ]
%17 = add nsw i32 %16, %5
%18 = add nuw nsw i32 %4, 1
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %3
20: ; preds = %15
%21 = sdiv i32 %17, 10
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %21)
ret void
}