#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 evkeyvalq {
  int dummy;
};

/* Variables and functions */
double atof(char const *);
char *evhttp_find_header(struct evkeyvalq *, char const *);
double get_double_argument(struct evkeyvalq *args, const char *key,
                           double default_value) {
  const char *tmp;
  if (!key) {
    return default_value;
  }
  tmp = evhttp_find_header(args, key);
  if (tmp) {
    return atof(tmp);
  }
  return default_value;
}


x86 assembly (clang, -O0):
<get_double_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114f <get_double_argument+0x2f>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1188 <get_double_argument+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <evhttp_find_header@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117e <get_double_argument+0x5e>
mov    -0x28(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1188 <get_double_argument+0x68>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_double_argument>:
test   %rsi,%rsi
je     1147 <get_double_argument+0x27>
push   %rax
movsd  %xmm0,(%rsp)
call   1040 <evhttp_find_header@plt>
movsd  (%rsp),%xmm0
test   %rax,%rax
lea    0x8(%rsp),%rsp
je     1147 <get_double_argument+0x27>
mov    %rax,%rdi
jmp    1030 <atof@plt>
ret

LLVM IR (-O0):
%struct.evkeyvalq = type { i32 }
define double @get_double_argument(%struct.evkeyvalq* %0, i8* %1, double %2) {
%4 = alloca double
%5 = alloca %struct.evkeyvalq*
%6 = alloca i8*
%7 = alloca double
%8 = alloca i8*
store %struct.evkeyvalq* %0, %struct.evkeyvalq** %5
store i8* %1, i8** %6
store double %2, double* %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = load double, double* %7
store double %12, double* %4
br label %24
13: ; preds = %3
%14 = load %struct.evkeyvalq*, %struct.evkeyvalq** %5
%15 = load i8*, i8** %6
%16 = call i8* @evhttp_find_header(%struct.evkeyvalq* %14, i8* %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %8
%21 = call double @atof(i8* %20)
store double %21, double* %4
br label %24
22: ; preds = %13
%23 = load double, double* %7
store double %23, double* %4
br label %24
24: ; preds = %22, %19, %11
%25 = load double, double* %4
ret double %25
}

LLVM IR (-O2):
%struct.evkeyvalq = type { i32 }
define double @get_double_argument(%struct.evkeyvalq* %0, i8* %1, double %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = tail call i8* @evhttp_find_header(%struct.evkeyvalq* %0, i8* %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call double @atof(i8* %6)
br label %10
10: ; preds = %5, %3, %8
%11 = phi double [ %9, %8 ], [ %2, %3 ], [ %2, %5 ]
ret double %11
}