#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 *, double *);
int main(void) {
  double currentNum, largestNum;
  bool moreNumbers = true;
  largestNum = 0;
  for (;;) {
    printf("Enter a number: ");
    scanf("%lf", &currentNum);
    if (currentNum <= 0) {
      break;
    } else if (currentNum > largestNum) {
      largestNum = currentNum;
    }
  }
  printf("The largest number entered was %lf\n", largestNum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     116f <main+0x4f>
jmp    1193 <main+0x73>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1189 <main+0x69>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118e <main+0x6e>
jmp    113e <main+0x1e>
movsd  -0x18(%rbp),%xmm0
lea    0xe76(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    11a8 <main+0x88>
lea    0xeac(%rip),%r14
lea    0xeb6(%rip),%r15
mov    %rsp,%rbx
xorpd  %xmm1,%xmm1
nopw   0x0(%rax,%rax,1)
maxsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
movapd %xmm0,%xmm1
jb     1170 <main+0x50>
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [36 x i8] c"The largest number entered was %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
store double 0.000000e+00, double* %3
br label %5
5: ; preds = %18, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = load double, double* %2
%9 = fcmp ole double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %5
br label %19
11: ; preds = %5
%12 = load double, double* %2
%13 = load double, double* %3
%14 = fcmp ogt double %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load double, double* %2
store double %16, double* %3
br label %17
17: ; preds = %15, %11
br label %18
18: ; preds = %17
br label %5
19: ; preds = %10
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [36 x i8] c"The largest number entered was %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ugt double %5, 0.000000e+00
br i1 %6, label %7, label %16
7: ; preds = %0, %7
%8 = phi double [ %14, %7 ], [ %5, %0 ]
%9 = phi double [ %11, %7 ], [ 0.000000e+00, %0 ]
%10 = fcmp ogt double %8, %9
%11 = select i1 %10, double %8, double %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%14 = load double, double* %1
%15 = fcmp ugt double %14, 0.000000e+00
br i1 %15, label %7, label %16
16: ; preds = %7, %0
%17 = phi double [ 0.000000e+00, %0 ], [ %11, %7 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %17)
ret i32 0
}