#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 */
int /*<<< orphan*/ getstr(char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, double *);
double GetDouble(char *title, double deflt, 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);
    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
call   1040 <getstr@plt>
movsbl -0x70(%rbp),%eax
cmp    $0x3f,%eax
jne    11ea <GetDouble+0xaa>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ea <GetDouble+0xaa>
mov    -0x20(%rbp),%rsi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    122b <GetDouble+0xeb>
lea    -0x70(%rbp),%rdi
lea    0xe28(%rip),%rsi
lea    -0xc8(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    1219 <GetDouble+0xd9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1230 <GetDouble+0xf0>
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1230 <GetDouble+0xf0>
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
cmpb   $0x0,(%rsi)
lea    0xeb3(%rip),%rax
lea    0xe9a(%rip),%rcx
cmove  %rax,%rcx
lea    0xe88(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe89(%rip),%rsi
lea    0x60(%rsp),%r15
mov    %r15,%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <getstr@plt>
cmpb   $0x3f,0x10(%rsp)
jne    1240 <GetDouble+0x100>
lea    0xe3b(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe49(%rip),%rbp
lea    0x60(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     1240 <GetDouble+0x100>
lea    0xe18(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
cmpb   $0x0,(%rbx)
lea    0xe09(%rip),%rcx
lea    0xe14(%rip),%rax
cmove  %rax,%rcx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1040 <getstr@plt>
cmpb   $0x3f,0x10(%rsp)
je     11e0 <GetDouble+0xa0>
lea    0xdd6(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
je     1265 <GetDouble+0x125>
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)
%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*
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, 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)
%13 = 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* %12)
%14 = 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)
%15 = call i32 @getstr(i8* %7, i8* %8, i8* %7)
%16 = load i8, i8* %7
%17 = icmp eq i8 %16, 63
br i1 %17, label %18, label %31
18: ; preds = %3, %21
%19 = load i8, i8* %2
%20 = icmp eq i8 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%23 = load i8, i8* %2
%24 = icmp eq i8 %23, 0
%25 = select i1 %24, 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)
%26 = 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* %25)
%27 = 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)
%28 = call i32 @getstr(i8* %7, i8* %8, i8* %7)
%29 = load i8, i8* %7
%30 = icmp eq i8 %29, 63
br i1 %30, label %18, label %31
31: ; preds = %21, %18, %3
%32 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %6)
%33 = icmp eq i32 %32, 0
%34 = load double, double* %6
%35 = select i1 %33, double %1, double %34
ret double %35
}