#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ getstr(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, double *);
double GetDouble(const char *title, double deflt, const char *help) {
  char s[80], sdeflt[80];
  double newval;
  while (1) {
    sprintf(s, "\n%s:%s", title, (*help) ? " (Type ? for Help)" : "");
    sprintf(sdeflt, "%g", deflt);
    getstr(s, sdeflt, s, sizeof(s));
    if (*s == '?' && *help)
      printf("%s", help);
    else {
      if (!sscanf(s, "%lf", &newval))
        return (deflt);
      return (newval);
    }
  }
}


x86 assembly (clang, -O0):
<GetDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
lea    0xeab(%rip),%rcx
lea    0xe92(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0xc0(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xe7d(%rip),%rsi
mov    $0x1,%al
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x50,%ecx
call   1040 <getstr@plt>
movsbl -0x70(%rbp),%eax
cmp    $0x3f,%eax
jne    11ef <GetDouble+0xaf>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ef <GetDouble+0xaf>
mov    -0x20(%rbp),%rsi
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
jmp    1230 <GetDouble+0xf0>
lea    -0x70(%rbp),%rdi
lea    0xe23(%rip),%rsi
lea    -0xc8(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    121e <GetDouble+0xde>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1235 <GetDouble+0xf5>
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1235 <GetDouble+0xf5>
jmp    1158 <GetDouble+0x18>
movsd  -0x8(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetDouble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rbx
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
lea    0x10(%rsp),%r12
lea    0xeb2(%rip),%r13
lea    0x60(%rsp),%rbp
lea    0xe90(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,(%rbx)
lea    0xe8f(%rip),%rcx
je     1193 <GetDouble+0x53>
lea    0xe74(%rip),%rcx
mov    %r12,%rdi
lea    0xe63(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    $0x50,%ecx
call   1040 <getstr@plt>
cmpb   $0x3f,0x10(%rsp)
jne    11e5 <GetDouble+0xa5>
cmpb   $0x0,(%rbx)
je     11e5 <GetDouble+0xa5>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    1180 <GetDouble+0x40>
lea    0xe31(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
je     120a <GetDouble+0xca>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\0A%s:%s\00"
@.str.1 = [19 x i8] c" (Type ? for Help)\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%g\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%lf\00"
define double @GetDouble(i8* %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8*
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca double
store i8* %0, i8** %5
store double %1, double* %6
store i8* %2, i8** %7
br label %11
11: ; preds = %3, %48
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = load i8*, i8** %7
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %19)
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%22 = load double, double* %6
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), double %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%27 = call i32 @getstr(i8* %24, i8* %25, i8* %26, i32 80)
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 63
br i1 %31, label %32, label %40
32: ; preds = %11
%33 = load i8*, i8** %7
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %7
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %38)
br label %48
40: ; preds = %32, %11
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %10)
%43 = icmp ne i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = load double, double* %6
store double %45, double* %4
br label %49
46: ; preds = %40
%47 = load double, double* %10
store double %47, double* %4
br label %49
48: ; preds = %37
br label %11
49: ; preds = %46, %44
%50 = load double, double* %4
ret double %50
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0A%s:%s\00"
@.str.1 = [19 x i8] c" (Type ? for Help)\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%g\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%lf\00"
define double @GetDouble(i8* %0, double %1, i8* %2) {
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca double
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%9 = bitcast double* %6 to i8*
br label %10
10: ; preds = %22, %3
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0)
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %13)
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), double %1)
%16 = call i32 @getstr(i8* %7, i8* %8, i8* %7, i32 80)
%17 = load i8, i8* %7
%18 = icmp eq i8 %17, 63
br i1 %18, label %19, label %24
19: ; preds = %10
%20 = load i8, i8* %2
%21 = icmp eq i8 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %10
24: ; preds = %19, %10
%25 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %6)
%26 = icmp eq i32 %25, 0
%27 = load double, double* %6
%28 = select i1 %26, double %1, double %27
ret double %28
}