#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*/ LC_ALL;
int /*<<< orphan*/ printf(char *, float, ...);
int /*<<< orphan*/ scanf(char *, float *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "");
  int i = 0;
  float valor[3];
  float resultado = 0;
  for (i = 0; i < 3; i++) {
    printf("Insira o valor[%d]: ", i);
    scanf("%f", &valor[i]);
    resultado += valor[i] * valor[i];
  }
  printf(
      "O resultado da soma dos quadrados do array [%.2f, %.2f, %.2f] é: %f\n",
      valor[0], valor[1], valor[2], resultado);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xf0e(%rip),%rsi
call   1040 <setlocale@plt>
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d6 <main+0xa6>
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xe80(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x14(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe78(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
movss  -0x14(%rbp,%rax,4),%xmm0
movslq -0x8(%rbp),%rax
movss  -0x14(%rbp,%rax,4),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x3a>
movss  -0x14(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x18(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xe1b(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xf22(%rip),%rsi
call   1040 <setlocale@plt>
lea    0xeb9(%rip),%r14
xorps  %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  0xe82(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xe6c(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xe3b(%rip),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm2
movaps %xmm0,%xmm3
mulss  %xmm0,%xmm3
addss  0x8(%rsp),%xmm3
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm3,%xmm3
lea    0xe12(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Insira o valor[%d]: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [70 x i8] c"O resultado da soma dos quadrados do array [%.2f, %.2f, %.2f] \C3\A9: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x float]
%4 = alloca float
store i32 0, i32* %1
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
store float 0.000000e+00, float* %4
store i32 0, i32* %2
br label %7
7: ; preds = %28, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sitofp i32 %11 to float
%13 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), float %12)
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %16)
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 %19
%21 = load float, float* %20
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 %23
%25 = load float, float* %24
%26 = load float, float* %4
%27 = call float @llvm.fmuladd.f32(float %21, float %25, float %26)
store float %27, float* %4
br label %28
28: ; preds = %10
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %7
31: ; preds = %7
%32 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
%33 = load float, float* %32
%34 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%35 = load float, float* %34
%36 = fpext float %35 to double
%37 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = load float, float* %4
%41 = fpext float %40 to double
%42 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), float %33, double %36, double %39, double %41)
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"Insira o valor[%d]: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [70 x i8] c"O resultado da soma dos quadrados do array [%.2f, %.2f, %.2f] \C3\A9: %f\0A\00"
define i32 @main() {
%1 = alloca [3 x float]
%2 = load i32, i32* @LC_ALL
%3 = tail call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [3 x float]* %1 to i8*
%5 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), float 0.000000e+00)
%6 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%8 = load float, float* %6
%9 = call float @llvm.fmuladd.f32(float %8, float %8, float 0.000000e+00)
%10 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), float 1.000000e+00)
%11 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %11)
%13 = load float, float* %11
%14 = call float @llvm.fmuladd.f32(float %13, float %13, float %9)
%15 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), float 2.000000e+00)
%16 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %16)
%18 = load float, float* %16
%19 = call float @llvm.fmuladd.f32(float %18, float %18, float %14)
%20 = load float, float* %6
%21 = load float, float* %11
%22 = fpext float %21 to double
%23 = fpext float %18 to double
%24 = fpext float %19 to double
%25 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), float %20, double %22, double %23, double %24)
ret i32 0
}