#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 */
char *config_get_option(char const *);
int sscanf(char const *, char *, float *);
float config_get_foption(const char *key, float err_return) {
  const char *optstr = config_get_option(key);
  float retval;
  int success;
  if (!optstr) {
    return err_return;
  }
  success = sscanf(optstr, "%f", &retval);
  if (success) {
    return retval;
  } else {
    return err_return;
  }
}


x86 assembly (clang, -O0):
<config_get_foption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <config_get_option@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1158 <config_get_foption+0x38>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1192 <config_get_foption+0x72>
mov    -0x20(%rbp),%rdi
lea    0xe9d(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1188 <config_get_foption+0x68>
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1192 <config_get_foption+0x72>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_get_foption>:
push   %rax
movss  %xmm0,(%rsp)
call   1030 <config_get_option@plt>
test   %rax,%rax
je     1155 <config_get_foption+0x35>
lea    0xec9(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
movss  (%rsp),%xmm0
je     1153 <config_get_foption+0x33>
movss  0x4(%rsp),%xmm0
pop    %rax
ret
movss  (%rsp),%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define float @config_get_foption(i8* %0, float %1) {
%3 = alloca float
%4 = tail call i8* @config_get_option(i8* %0)
%5 = bitcast float* %3 to i8*
%6 = icmp eq i8* %4, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%9 = icmp eq i32 %8, 0
%10 = load float, float* %3
%11 = select i1 %9, float %1, float %10
br label %12
12: ; preds = %7, %2
%13 = phi float [ %1, %2 ], [ %11, %7 ]
ret float %13
}