#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() {
  int i, numValues;
  float sum = 0.0F, value;
  while (1) {
    printf("\nEnter a value in the range of 3 to 6: ");
    scanf("%d", &numValues);
    if (numValues >= 3 && numValues <= 6)
      break;
    printf("Out of range; please try again.\n");
  }
  for (i = 1; i <= numValues; ++i) {
    printf("Enter value %d: ", i);
    scanf("%f", &value);
    sum += value;
  }
  printf("The sum of the %d values was %2.2f\n\n", numValues, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x3,-0xc(%rbp)
jl     1170 <main+0x50>
cmpl   $0x6,-0xc(%rbp)
jg     1170 <main+0x50>
jmp    1183 <main+0x63>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11d6 <main+0xb6>
mov    -0x8(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118a <main+0x6a>
mov    -0xc(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%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   %rbx
sub    $0x18,%rsp
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffffd,%eax
cmp    $0x4,%eax
jb     11bb <main+0x8b>
lea    0xef6(%rip),%r14
lea    0xe8b(%rip),%r15
lea    0xeac(%rip),%rbx
lea    0xc(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffffd,%eax
cmp    $0x3,%eax
ja     1190 <main+0x60>
xorps  %xmm0,%xmm0
lea    0xe66(%rip),%r14
lea    0xe70(%rip),%r15
lea    0x14(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm0,0x10(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
mov    0xc(%rsp),%esi
cmp    %esi,%ebp
jl     11e0 <main+0xb0>
cvtss2sd %xmm0,%xmm0
lea    0xe1e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0AEnter a value in the range of 3 to 6: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Out of range; please try again.\0A\00"
@.str.3 = [17 x i8] c"Enter value %d: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [37 x i8] c"The sum of the %d values was %2.2f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
br label %6
6: ; preds = %0, %15
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 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), i32* %3)
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 3
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 6
br i1 %13, label %14, label %15
14: ; preds = %11
br label %17
15: ; preds = %11, %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %6
17: ; preds = %14
store i32 1, i32* %2
br label %18
18: ; preds = %29, %17
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%26 = load float, float* %5
%27 = load float, float* %4
%28 = fadd float %27, %26
store float %28, float* %4
br label %29
29: ; preds = %22
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %18
32: ; preds = %18
%33 = load i32, i32* %3
%34 = load float, float* %4
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %33, double %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"\0AEnter a value in the range of 3 to 6: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"Enter value %d: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [37 x i8] c"The sum of the %d values was %2.2f\0A\0A\00"
@str = [32 x i8] c"Out of range; please try again.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add i32 %7, -3
%9 = icmp ult i32 %8, 4
br i1 %9, label %17, label %10
10: ; preds = %0, %10
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = add i32 %14, -3
%16 = icmp ult i32 %15, 4
br i1 %16, label %17, label %10
17: ; preds = %10, %0
br label %18
18: ; preds = %17, %18
%19 = phi float [ %24, %18 ], [ 0.000000e+00, %17 ]
%20 = phi i32 [ %25, %18 ], [ 1, %17 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%23 = load float, float* %2
%24 = fadd float %19, %23
%25 = add nuw nsw i32 %20, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %20, %26
br i1 %27, label %18, label %28
28: ; preds = %18
%29 = fpext float %24 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %26, double %29)
ret i32 0
}