#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 */
float atof(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ stdin;
int main() {
  char line[64];
  while (fgets(line, 64, stdin)) {
    float input = atof(line);
    float output = input * 2;
    output = output > 8 ? 8 : output;
    printf("%f\n", output);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11d2 <main+0xa2>
lea    -0x50(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x54(%rbp)
movss  0xe8e(%rip),%xmm0
mulss  -0x54(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x58(%rbp),%xmm0
movss  0xe73(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11a8 <main+0x78>
movss  0xe62(%rip),%xmm0
movss  %xmm0,-0x5c(%rbp)
jmp    11b2 <main+0x82>
movss  -0x58(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x5c(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x58(%rbp),%xmm0
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    0x2ea8(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1198 <main+0x68>
mov    %rsp,%rbx
lea    0xea5(%rip),%r14
nop
mov    %rbx,%rdi
call   1030 <atof@plt>
addss  %xmm0,%xmm0
movss  0xe8c(%rip),%xmm1
minss  %xmm0,%xmm1
mov    %r14,%rdi
movaps %xmm1,%xmm0
call   1040 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
br label %5
5: ; preds = %20, %0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 64, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%12 = call float @atof(i8* %11)
store float %12, float* %3
%13 = load float, float* %3
%14 = fmul float %13, 2.000000e+00
store float %14, float* %4
%15 = load float, float* %4
%16 = fcmp ogt float %15, 8.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %10
br label %20
18: ; preds = %10
%19 = load float, float* %4
br label %20
20: ; preds = %18, %17
%21 = phi float [ 8.000000e+00, %17 ], [ %19, %18 ]
store float %21, float* %4
%22 = load float, float* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %22)
br label %5
24: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i64 @fgets(i8* %2, i32 64, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %0, %6
%7 = call float @atof(i8* %2)
%8 = fmul float %7, 2.000000e+00
%9 = fcmp ogt float %8, 8.000000e+00
%10 = select i1 %9, float 8.000000e+00, float %8
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %10)
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %2, i32 64, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %0
ret i32 0
}