#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 */
double DBL_MIN;
char EOF;
int EXIT_SUCCESS;
scalar_t__ ShouldTerminate(double);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int scanf(char *, double *);
int main(void) {
  double number = 0.0;
  double max = DBL_MIN;
  int count = 0;
  char c = '\0';
  while (1) {
    printf("Please enter a number. If done, please enter a 0 or a negative "
           "number: ");
    while (scanf("%lf", &number) != 1) {
      puts("Input invalid. Please try entering this number again.");
      while ((c = getchar()) != '\n' && c != EOF)
        continue;
    }
    while ((c = getchar()) != '\n' && c != EOF)
      continue;
    printf("Number %g accepted.\n", number);
    putchar('\n');
    if (ShouldTerminate(number)) {
      break;
    }
    max = (number > max) ? number : max;
    ++count;
  }
  if (count < 1) {
    puts("No numbers were entered.");
  } else {
    printf("The largest number entered was: %g", max);
  }
  getchar();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e52(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x1d(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
je     1210 <main+0xb0>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1e(%rbp)
je     11f6 <main+0x96>
movsbl -0x1d(%rbp),%eax
mov    0x2dfd(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    1206 <main+0xa6>
jmp    120b <main+0xab>
jmp    11c5 <main+0x65>
jmp    11a0 <main+0x40>
jmp    1215 <main+0xb5>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1f(%rbp)
je     1246 <main+0xe6>
movsbl -0x1d(%rbp),%eax
mov    0x2dad(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
test   $0x1,%al
jne    1256 <main+0xf6>
jmp    125b <main+0xfb>
jmp    1215 <main+0xb5>
movsd  -0x10(%rbp),%xmm0
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  -0x10(%rbp),%xmm0
call   1070 <ShouldTerminate@plt>
cmp    $0x0,%rax
je     1291 <main+0x131>
jmp    12d2 <main+0x172>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12b0 <main+0x150>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ba <main+0x15a>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <main+0x32>
cmpl   $0x1,-0x1c(%rbp)
jge    12ed <main+0x18d>
lea    0xdb4(%rip),%rdi
call   1040 <puts@plt>
jmp    1300 <main+0x1a0>
movsd  -0x18(%rbp),%xmm0
lea    0xdb7(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e52(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xeb9(%rip),%r15
lea    0x8(%rsp),%rbx
mov    0x2e4d(%rip),%rbp
lea    0xee0(%rip),%r12
lea    0xea3(%rip),%r13
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
je     1200 <main+0xa0>
mov    %r13,%rdi
call   1040 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     11c0 <main+0x60>
cmp    0x0(%rbp),%al
jne    11e0 <main+0x80>
jmp    11c0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     1210 <main+0xb0>
cmp    0x0(%rbp),%al
jne    1200 <main+0xa0>
movsd  0x8(%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm0
call   1070 <ShouldTerminate@plt>
test   %rax,%rax
jne    1255 <main+0xf5>
movsd  0x8(%rsp),%xmm0
maxsd  0x10(%rsp),%xmm0
add    $0x1,%r14d
movsd  %xmm0,0x10(%rsp)
jmp    11b0 <main+0x50>
test   %r14d,%r14d
je     1270 <main+0x110>
lea    0xe4f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
jmp    127c <main+0x11c>
lea    0xe20(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_MIN = global double 0.000000e+00
@.str = [72 x i8] c"Please enter a number. If done, please enter a 0 or a negative number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [54 x i8] c"Input invalid. Please try entering this number again.\00"
@EOF = global i8 0
@.str.3 = [21 x i8] c"Number %g accepted.\0A\00"
@.str.4 = [25 x i8] c"No numbers were entered.\00"
@.str.5 = [35 x i8] c"The largest number entered was: %g\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store double 0.000000e+00, double* %2
%6 = load double, double* @DBL_MIN
store double %6, double* %3
store i32 0, i32* %4
store i8 0, i8* %5
br label %7
7: ; preds = %0, %58
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %27, %7
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %26, %12
%15 = call signext i8 (...) @getchar()
store i8 %15, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br label %24
24: ; preds = %18, %14
%25 = phi i1 [ false, %14 ], [ %23, %18 ]
br i1 %25, label %26, label %27
26: ; preds = %24
br label %14
27: ; preds = %24
br label %9
28: ; preds = %9
br label %29
29: ; preds = %41, %28
%30 = call signext i8 (...) @getchar()
store i8 %30, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i8, i8* %5
%35 = sext i8 %34 to i32
%36 = load i8, i8* @EOF
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br label %39
39: ; preds = %33, %29
%40 = phi i1 [ false, %29 ], [ %38, %33 ]
br i1 %40, label %41, label %42
41: ; preds = %39
br label %29
42: ; preds = %39
%43 = load double, double* %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %43)
%45 = call i32 @putchar(i8 signext 10)
%46 = load double, double* %2
%47 = call i64 @ShouldTerminate(double %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %42
br label %62
50: ; preds = %42
%51 = load double, double* %2
%52 = load double, double* %3
%53 = fcmp ogt double %51, %52
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = load double, double* %2
br label %58
56: ; preds = %50
%57 = load double, double* %3
br label %58
58: ; preds = %56, %54
%59 = phi double [ %55, %54 ], [ %57, %56 ]
store double %59, double* %3
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %7
62: ; preds = %49
%63 = load i32, i32* %4
%64 = icmp slt i32 %63, 1
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %70
67: ; preds = %62
%68 = load double, double* %3
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), double %68)
br label %70
70: ; preds = %67, %65
%71 = call signext i8 (...) @getchar()
%72 = load i32, i32* @EXIT_SUCCESS
ret i32 %72
}

LLVM IR (-O2):
@DBL_MIN = global double 0.000000e+00
@.str = [72 x i8] c"Please enter a number. If done, please enter a 0 or a negative number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [54 x i8] c"Input invalid. Please try entering this number again.\00"
@EOF = global i8 0
@.str.3 = [21 x i8] c"Number %g accepted.\0A\00"
@.str.4 = [25 x i8] c"No numbers were entered.\00"
@.str.5 = [35 x i8] c"The largest number entered was: %g\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = load double, double* @DBL_MIN
br label %4
4: ; preds = %35, %0
%5 = phi double [ %3, %0 ], [ %38, %35 ]
%6 = phi i32 [ 0, %0 ], [ %39, %35 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %11, %4
br label %22
11: ; preds = %16
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %10, label %14
14: ; preds = %4, %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %16, %14
%17 = call signext i8 (...) @getchar()
%18 = icmp ne i8 %17, 10
%19 = load i8, i8* @EOF
%20 = icmp ne i8 %17, %19
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %16, label %11
22: ; preds = %10, %22
%23 = call signext i8 (...) @getchar()
%24 = icmp ne i8 %23, 10
%25 = load i8, i8* @EOF
%26 = icmp ne i8 %23, %25
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %22, label %28
28: ; preds = %22
%29 = load double, double* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = call i32 @putchar(i8 signext 10)
%32 = load double, double* %1
%33 = call i64 @ShouldTerminate(double %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %28
%36 = load double, double* %1
%37 = fcmp ogt double %36, %5
%38 = select i1 %37, double %36, double %5
%39 = add nuw nsw i32 %6, 1
br label %4
40: ; preds = %28
%41 = icmp eq i32 %6, 0
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), double %5)
br label %46
46: ; preds = %44, %42
%47 = call signext i8 (...) @getchar()
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}