#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 *);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
float get_float(char *ch, float no) {
  int len = 100;
  char *tstr;
  char str[100];
  printf("%s: ", ch);
  tstr = fgets(str, len, stdin);
  if (tstr == NULL)
    return (no);
  return (atof(str));
}


x86 assembly (clang, -O0):
<get_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1191 <get_float+0x61>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a2 <get_float+0x72>
lea    -0x90(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_float>:
sub    $0x78,%rsp
movss  %xmm0,0xc(%rsp)
mov    %rdi,%rsi
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
movss  0xc(%rsp),%xmm0
test   %rax,%rax
je     1176 <get_float+0x46>
lea    0x10(%rsp),%rdi
call   1030 <atof@plt>
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define float @get_float(i8* %0, float %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca float
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [100 x i8]
store i8* %0, i8** %4
store float %1, float* %5
store i32 100, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%12 = load i32, i32* %6
%13 = load i32, i32* @stdin
%14 = call i8* @fgets(i8* %11, i32 %12, i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load float, float* %5
store float %18, float* %3
br label %22
19: ; preds = %2
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%21 = call float @atof(i8* %20)
store float %21, float* %3
br label %22
22: ; preds = %19, %17
%23 = load float, float* %3
ret float %23
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@stdin = global i32 0
define float @get_float(i8* %0, float %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stdin
%7 = call i8* @fgets(i8* %4, i32 100, i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call float @atof(i8* %4)
br label %11
11: ; preds = %2, %9
%12 = phi float [ %10, %9 ], [ %1, %2 ]
ret float %12
}