#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 counter, numValues;
  double numEntered, largest;
  printf("do-while & while Loop Example 5\n\n");
  do {
    printf("Enter value in range of 3 to 6: ");
    scanf("%d", &numValues);
    if (numValues < 3 || numValues > 6)
      printf("Value out of range.  Try again.\n");
  } while (numValues < 3 || numValues > 6);
  printf("\n");
  counter = 1;
  while (counter <= numValues) {
    printf("Enter value %d: ", counter);
    scanf("%lf", &numEntered);
    if (counter == 1)
      largest = numEntered;
    else if (numEntered > largest)
      largest = numEntered;
    counter++;
  }
  printf("\nThe largest value entered was %4.4lf.\n\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x3,-0xc(%rbp)
jl     1171 <main+0x51>
cmpl   $0x6,-0xc(%rbp)
jle    117f <main+0x5f>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1184 <main+0x64>
mov    $0x1,%al
cmpl   $0x3,-0xc(%rbp)
mov    %al,-0x21(%rbp)
jl     119d <main+0x7d>
cmpl   $0x6,-0xc(%rbp)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    113d <main+0x1d>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1232 <main+0x112>
mov    -0x8(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1205 <main+0xe5>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1224 <main+0x104>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    121f <main+0xff>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1224 <main+0x104>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bd <main+0x9d>
movsd  -0x20(%rbp),%xmm0
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf10(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%r14
lea    0xebc(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xf12(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffff9,%eax
cmp    $0xfffffffb,%eax
ja     11b7 <main+0x77>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%eax
add    $0xfffffff9,%eax
cmp    $0xfffffffc,%eax
jb     1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm1
cmpl   $0x2,0x4(%rsp)
jl     124a <main+0x10a>
lea    0xe24(%rip),%r14
lea    0xe2e(%rip),%r15
lea    0x8(%rsp),%r12
nopl   0x0(%rax)
movsd  %xmm1,0x10(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
maxsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
cmp    0x4(%rsp),%ebx
jl     1210 <main+0xd0>
jmp    124e <main+0x10e>
movapd %xmm1,%xmm0
lea    0xde4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"do-while & while Loop Example 5\0A\0A\00"
@.str.1 = [33 x i8] c"Enter value in range of 3 to 6: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [33 x i8] c"Value out of range. Try again.\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [17 x i8] c"Enter value %d: \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [41 x i8] c"\0AThe largest value entered was %4.4lf.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %24, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 3
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 6
br i1 %14, label %15, label %17
15: ; preds = %12, %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 3
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 6
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ true, %18 ], [ %23, %21 ]
br i1 %25, label %7, label %26
26: ; preds = %24
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %28
28: ; preds = %47, %26
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %50
32: ; preds = %28
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %4)
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = load double, double* %4
store double %39, double* %5
br label %47
40: ; preds = %32
%41 = load double, double* %4
%42 = load double, double* %5
%43 = fcmp ogt double %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load double, double* %4
store double %45, double* %5
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46, %38
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %28
50: ; preds = %28
%51 = load double, double* %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), double %51)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [33 x i8] c"Enter value in range of 3 to 6: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.5 = [17 x i8] c"Enter value %d: \00"
@.str.6 = [4 x i8] c"%lf\00"
@.str.7 = [41 x i8] c"\0AThe largest value entered was %4.4lf.\0A\0A\00"
@str = [33 x i8] c"do-while & while Loop Example 5\0A\00"
@str.8 = [32 x i8] c"Value out of range. Try again.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %12, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -7
%11 = icmp ult i32 %10, -4
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = add i32 %14, -7
%16 = icmp ult i32 %15, -4
br i1 %16, label %6, label %17
17: ; preds = %6, %12
%18 = call i32 @putchar(i32 10)
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 1)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %2)
%23 = load double, double* %2
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %37
26: ; preds = %17, %26
%27 = phi double [ %33, %26 ], [ %23, %17 ]
%28 = phi i32 [ %34, %26 ], [ 2, %17 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %2)
%31 = load double, double* %2
%32 = fcmp ogt double %31, %27
%33 = select i1 %32, double %31, double %27
%34 = add nuw nsw i32 %28, 1
%35 = load i32, i32* %1
%36 = icmp slt i32 %28, %35
br i1 %36, label %26, label %37
37: ; preds = %26, %17
%38 = phi double [ %23, %17 ], [ %33, %26 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), double %38)
ret i32 0
}