#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 */
struct config_setting_t {
  int dummy;
};

/* Variables and functions */
struct config_setting_t *
config_setting_get_elem(struct config_setting_t const *, int);
double config_setting_get_float(struct config_setting_t *);
double config_setting_get_float_elem(const struct config_setting_t *vector,
                                     int idx) {
  struct config_setting_t *element = config_setting_get_elem(vector, idx);
  return (element ? config_setting_get_float(element) : 0.0);
}


x86 assembly (clang, -O0):
<config_setting_get_float_elem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <config_setting_get_elem@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115d <config_setting_get_float_elem+0x3d>
mov    -0x18(%rbp),%rdi
call   1040 <config_setting_get_float@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    116a <config_setting_get_float_elem+0x4a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    116a <config_setting_get_float_elem+0x4a>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_setting_get_float_elem>:
push   %rax
call   1030 <config_setting_get_elem@plt>
test   %rax,%rax
je     1134 <config_setting_get_float_elem+0x14>
mov    %rax,%rdi
pop    %rax
jmp    1040 <config_setting_get_float@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%struct.config_setting_t = type { i32 }
define double @config_setting_get_float_elem(%struct.config_setting_t* %0, i32 %1) {
%3 = alloca %struct.config_setting_t*
%4 = alloca i32
%5 = alloca %struct.config_setting_t*
store %struct.config_setting_t* %0, %struct.config_setting_t** %3
store i32 %1, i32* %4
%6 = load %struct.config_setting_t*, %struct.config_setting_t** %3
%7 = load i32, i32* %4
%8 = call %struct.config_setting_t* @config_setting_get_elem(%struct.config_setting_t* %6, i32 %7)
store %struct.config_setting_t* %8, %struct.config_setting_t** %5
%9 = load %struct.config_setting_t*, %struct.config_setting_t** %5
%10 = icmp ne %struct.config_setting_t* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load %struct.config_setting_t*, %struct.config_setting_t** %5
%13 = call double @config_setting_get_float(%struct.config_setting_t* %12)
br label %15
14: ; preds = %2
br label %15
15: ; preds = %14, %11
%16 = phi double [ %13, %11 ], [ 0.000000e+00, %14 ]
ret double %16
}

LLVM IR (-O2):
%struct.config_setting_t = type { i32 }
define double @config_setting_get_float_elem(%struct.config_setting_t* %0, i32 %1) {
%3 = tail call %struct.config_setting_t* @config_setting_get_elem(%struct.config_setting_t* %0, i32 %1)
%4 = icmp eq %struct.config_setting_t* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call double @config_setting_get_float(%struct.config_setting_t* %3)
br label %7
7: ; preds = %2, %5
%8 = phi double [ %6, %5 ], [ 0.000000e+00, %2 ]
ret double %8
}