#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 main() {
  char StudentName[100];
  float ExamValue, Sum, Avg;
  int students, exams;
  for (students = 0; students < 5; students++) {
    Sum = 0.0;
    printf("Enter Student Name: \n");
    scanf("%s", StudentName);
    for (exams = 0; exams < 3; exams++) {
      printf("Enter exam grade: \n");
      scanf("%f", &ExamValue);
      Sum += ExamValue;
    }
    Avg = Sum / 3.0;
    printf("Average for %s is %f\n", StudentName, Avg);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x80(%rbp)
cmpl   $0x5,-0x80(%rbp)
jge    120c <main+0xec>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x78(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x3,-0x84(%rbp)
jge    11c5 <main+0xa5>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x74(%rbp),%xmm0
addss  -0x78(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1175 <main+0x55>
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x7c(%rbp)
lea    -0x70(%rbp),%rsi
movss  -0x7c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    1139 <main+0x19>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0x5,%r15d
lea    0x10(%rsp),%r12
lea    0xee9(%rip),%r13
lea    0xeb4(%rip),%rbx
lea    0xc(%rsp),%rbp
lea    0xeab(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  0xe54(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
divss  0xdfa(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%r15d
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter Student Name: \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"Enter exam grade: \0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [22 x i8] c"Average for %s is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
br label %8
8: ; preds = %36, %0
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %39
11: ; preds = %8
store float 0.000000e+00, float* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 0, i32* %7
br label %15
15: ; preds = %24, %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%21 = load float, float* %3
%22 = load float, float* %4
%23 = fadd float %22, %21
store float %23, float* %4
br label %24
24: ; preds = %18
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %15
27: ; preds = %15
%28 = load float, float* %4
%29 = fpext float %28 to double
%30 = fdiv double %29, 3.000000e+00
%31 = fptrunc double %30 to float
store float %31, float* %5
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %32, double %34)
br label %36
36: ; preds = %27
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %8
39: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [22 x i8] c"Average for %s is %f\0A\00"
@str = [21 x i8] c"Enter Student Name: \00"
@str.5 = [19 x i8] c"Enter exam grade: \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca float
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast float* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %24, %5 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%11 = load float, float* %2
%12 = fadd float %11, 0.000000e+00
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%15 = load float, float* %2
%16 = fadd float %12, %15
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%19 = load float, float* %2
%20 = fadd float %16, %19
%21 = fdiv float %20, 3.000000e+00
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %3, double %22)
%24 = add nuw nsw i32 %6, 1
%25 = icmp eq i32 %24, 5
br i1 %25, label %26, label %5
26: ; preds = %5
ret i32 0
}