#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 */
scalar_t__ arghelp_wanted(int, char **);
double atof(char const *);
char *basic_string_from_args(char const *, int, char **, char *);
int /*<<< orphan*/ printf(char *, ...);
double double_from_args(const char *key, int argc, char *argv[],
                        double default_value) {
  const char *string = basic_string_from_args(key, argc, argv, (char *)NULL);
  double result = (string == NULL) ? default_value : atof(string);
  if (arghelp_wanted(argc, argv)) {
    printf("ARGV %21s %8s default %8g ", key, "<double>", default_value);
    if (string == NULL)
      printf("\n");
    else
      printf("commandline %g\n", result);
  }
  return (result);
}


x86 assembly (clang, -O0):
<double_from_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <basic_string_from_args@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118a <double_from_args+0x4a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1198 <double_from_args+0x58>
mov    -0x28(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <arghelp_wanted@plt>
cmp    $0x0,%rax
je     120c <double_from_args+0xcc>
mov    -0x8(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
lea    0xe38(%rip),%rdi
lea    0xe4c(%rip),%rdx
mov    $0x1,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
jne    11f4 <double_from_args+0xb4>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1207 <double_from_args+0xc7>
movsd  -0x30(%rbp),%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    120c <double_from_args+0xcc>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_from_args>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
xor    %ecx,%ecx
call   1040 <basic_string_from_args@plt>
mov    %rax,%r15
movsd  0x10(%rsp),%xmm0
test   %rax,%rax
je     1185 <double_from_args+0x35>
mov    %r15,%rdi
call   1050 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <arghelp_wanted@plt>
test   %rax,%rax
je     11dd <double_from_args+0x8d>
lea    0xe5f(%rip),%rdi
lea    0xe73(%rip),%rdx
mov    %r14,%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
test   %r15,%r15
je     11d3 <double_from_args+0x83>
lea    0xe60(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
jmp    11dd <double_from_args+0x8d>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"ARGV %21s %8s default %8g \00"
@.str.1 = [9 x i8] c"<double>\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [16 x i8] c"commandline %g\0A\00"
define double @double_from_args(i8* %0, i32 %1, i8** %2, double %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca double
%9 = alloca i8*
%10 = alloca double
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store double %3, double* %8
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = load i8**, i8*** %7
%14 = call i8* @basic_string_from_args(i8* %11, i32 %12, i8** %13, i8* null)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load double, double* %8
br label %22
19: ; preds = %4
%20 = load i8*, i8** %9
%21 = call double @atof(i8* %20)
br label %22
22: ; preds = %19, %17
%23 = phi double [ %18, %17 ], [ %21, %19 ]
store double %23, double* %10
%24 = load i32, i32* %6
%25 = load i8**, i8*** %7
%26 = call i64 @arghelp_wanted(i32 %24, i8** %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = load double, double* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %30)
%32 = load i8*, i8** %9
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %39
36: ; preds = %28
%37 = load double, double* %10
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %37)
br label %39
39: ; preds = %36, %34
br label %40
40: ; preds = %39, %22
%41 = load double, double* %10
ret double %41
}

LLVM IR (-O2):
@.str = [27 x i8] c"ARGV %21s %8s default %8g \00"
@.str.1 = [9 x i8] c"<double>\00"
@.str.3 = [16 x i8] c"commandline %g\0A\00"
define double @double_from_args(i8* %0, i32 %1, i8** %2, double %3) {
%5 = tail call i8* @basic_string_from_args(i8* %0, i32 %1, i8** %2, i8* null)
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call double @atof(i8* %5)
br label %9
9: ; preds = %4, %7
%10 = phi double [ %8, %7 ], [ %3, %4 ]
%11 = tail call i64 @arghelp_wanted(i32 %1, i8** %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %3)
br i1 %6, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @putchar(i32 10)
br label %19
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %10)
br label %19
19: ; preds = %15, %17, %9
ret double %10
}