#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 *, float *);
int main() {
  float max = 0.0f, num;
  for (;;) {
    printf("Enter a number: ");
    scanf("%f", &num);
    if (num == 0) {
      printf("The largest number was: %.2f\n", max);
      return 0;
    } else {
      if (num > max) {
        max = num;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    118b <main+0x6b>
jp     118b <main+0x6b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11a4 <main+0x84>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11a9 <main+0x89>
jmp    1137 <main+0x17>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    115b <main+0x3b>
jnp    11b9 <main+0x99>
lea    0xe9e(%rip),%r14
lea    0xea8(%rip),%r15
lea    0x8(%rsp),%rbx
xorps  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
maxss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
jne    1180 <main+0x60>
jp     1180 <main+0x60>
cvtss2sd %xmm0,%xmm0
lea    0xe54(%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 = [3 x i8] c"%f\00"
@.str.2 = [30 x i8] c"The largest number was: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
br label %4
4: ; preds = %20, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%7 = load float, float* %3
%8 = fcmp oeq float %7, 0.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load float, float* %2
%11 = fpext float %10 to double
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %11)
ret i32 0
13: ; preds = %4
%14 = load float, float* %3
%15 = load float, float* %2
%16 = fcmp ogt float %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load float, float* %3
store float %18, float* %2
br label %19
19: ; preds = %17, %13
br label %20
20: ; preds = %19
br label %4
}

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