#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*/ free(char *);
char *get_string();
int /*<<< orphan*/ printf(char *, char *);
float strtof(char *, char **);
int get_float(float *x) {
  char *aux = get_string();
  char *aux2;
  float out;
  if (aux == NULL) {
    return 1;
  }
  out = strtof(aux, &aux2);
  if (aux2 == aux) {
    printf("\tInvalid. Expected number, got '%s'. Please input number: ", aux);
    free(aux);
    return get_float(x);
  } else {
    free(aux);
  }
  *x = out;
  return 0;
}


x86 assembly (clang, -O0):
<get_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <get_string@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117e <get_float+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <get_float+0x95>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <strtof@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11c8 <get_float+0x78>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1070 <get_float@plt>
mov    %eax,-0x4(%rbp)
jmp    11e5 <get_float+0x95>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_float>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <get_string@plt>
test   %rax,%rax
je     119a <get_float+0x4a>
mov    %rax,%rbx
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1060 <strtof@plt>
cmp    %rbx,0x10(%rsp)
je     11a7 <get_float+0x57>
mov    %rbx,%rdi
movss  %xmm0,0xc(%rsp)
call   1030 <free@plt>
movss  0xc(%rsp),%xmm0
movss  %xmm0,(%r14)
xor    %eax,%eax
jmp    119f <get_float+0x4f>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1070 <get_float@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"\09Invalid. Expected number, got '%s'. Please input number: \00"
define i32 @get_float(float* %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca float
store float* %0, float** %3
%7 = call i8* (...) @get_string()
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %30
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call float @strtof(i8* %12, i8** %5)
store float %13, float* %6
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = load float*, float** %3
%23 = call i32 @get_float(float* %22)
store i32 %23, i32* %2
br label %30
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %24
%28 = load float, float* %6
%29 = load float*, float** %3
store float %28, float* %29
store i32 0, i32* %2
br label %30
30: ; preds = %27, %17, %10
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [59 x i8] c"\09Invalid. Expected number, got '%s'. Please input number: \00"
define i32 @get_float(float* nocapture writeonly %0) {
%2 = alloca i8*
%3 = tail call i8* (...) @get_string()
%4 = bitcast i8** %2 to i8*
%5 = icmp eq i8* %3, null
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = call float @strtof(i8* %3, i8** %2)
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, %3
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = tail call i32 @free(i8* %3)
%13 = tail call i32 @get_float(float* %0)
br label %16
14: ; preds = %6
%15 = tail call i32 @free(i8* %3)
store float %7, float* %0
br label %16
16: ; preds = %1, %14, %10
%17 = phi i32 [ %13, %10 ], [ 0, %14 ], [ 1, %1 ]
ret i32 %17
}