#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);
int /*<<< orphan*/ scanf(char *, double *, double *, double *, double *,
                         double *, double *, double *, double *);
double calcStudentMark(int studentNumber) {
  double studentPoints[8], finalPoints = 0;
  printf("Please enter the points for student %d : ", studentNumber + 1);
  scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &studentPoints[0], &studentPoints[1],
        &studentPoints[2], &studentPoints[3], &studentPoints[4],
        &studentPoints[5], &studentPoints[6], &studentPoints[7]);
  for (int i = 0; i < 8; i++) {
    finalPoints += studentPoints[i];
  }
  return finalPoints;
}


x86 assembly (clang, -O0):
<calcStudentMark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x4(%rbp),%esi
add    $0x1,%esi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    -0x50(%rbp),%rdx
add    $0x8,%rdx
lea    -0x50(%rbp),%rcx
add    $0x10,%rcx
lea    -0x50(%rbp),%r8
add    $0x18,%r8
lea    -0x50(%rbp),%r9
add    $0x20,%r9
lea    -0x50(%rbp),%r11
add    $0x28,%r11
lea    -0x50(%rbp),%r10
add    $0x30,%r10
lea    -0x50(%rbp),%rax
add    $0x38,%rax
lea    0xe9f(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <scanf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x8,-0x5c(%rbp)
jge    11d1 <calcStudentMark+0xb1>
movslq -0x5c(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11a5 <calcStudentMark+0x85>
movsd  -0x58(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcStudentMark>:
sub    $0x48,%rsp
lea    0x1(%rdi),%esi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x20(%rsp),%r9
lea    0x28(%rsp),%r10
lea    0x30(%rsp),%r11
lea    0x38(%rsp),%rax
sub    $0x8,%rsp
lea    0xec9(%rip),%rdi
lea    0x8(%rsp),%rsi
push   %rax
push   %r11
push   %r10
call   1040 <scanf@plt>
add    $0x20,%rsp
xorpd  %xmm0,%xmm0
addsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
addsd  0x38(%rsp),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Please enter the points for student %d : \00"
@.str.1 = [32 x i8] c"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\00"
define double @calcStudentMark(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x double]
%4 = alloca double
%5 = alloca i32
store i32 %0, i32* %2
store double 0.000000e+00, double* %4
%6 = load i32, i32* %2
%7 = add nsw i32 %6, 1
%8 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 0
%10 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 1
%11 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 2
%12 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 3
%13 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 4
%14 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 5
%15 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 6
%16 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 7
%17 = call i32 @scanf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double* %9, double* %10, double* %11, double* %12, double* %13, double* %14, double* %15, double* %16)
store i32 0, i32* %5
br label %18
18: ; preds = %28, %1
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 8
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 %23
%25 = load double, double* %24
%26 = load double, double* %4
%27 = fadd double %26, %25
store double %27, double* %4
br label %28
28: ; preds = %21
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
%32 = load double, double* %4
ret double %32
}

LLVM IR (-O2):
@.str = [42 x i8] c"Please enter the points for student %d : \00"
@.str.1 = [32 x i8] c"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\00"
define double @calcStudentMark(i32 %0) {
%2 = alloca [8 x double]
%3 = bitcast [8 x double]* %2 to i8*
%4 = add nsw i32 %0, 1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
%7 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 1
%8 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 2
%9 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 3
%10 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 4
%11 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 5
%12 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 6
%13 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 7
%14 = call i32 @scanf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), double* %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12, double* %13)
%15 = load double, double* %6
%16 = fadd double %15, 0.000000e+00
%17 = load double, double* %7
%18 = fadd double %16, %17
%19 = load double, double* %8
%20 = fadd double %18, %19
%21 = load double, double* %9
%22 = fadd double %20, %21
%23 = load double, double* %10
%24 = fadd double %22, %23
%25 = load double, double* %11
%26 = fadd double %24, %25
%27 = load double, double* %12
%28 = fadd double %26, %27
%29 = load double, double* %13
%30 = fadd double %28, %29
ret double %30
}