#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printerr(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int /*<<< orphan*/ stdin;
int getnum(char *line, double *val, const double *einput) {
  char s[40];
  printerr("%s = %.9E ? ", line, *val);
  if (einput) {
    *val = *einput;
    printerr("%.9E\n", *val);
    return 0;
  }
  if (!fgets(s, sizeof(s), stdin))
    exit(0);
  if (s[0] != '\0') {
    sscanf(s, "%lf", val);
    printerr("%.9E\n", *val);
  }
  return 0;
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1040 <printerr@plt>
cmpq   $0x0,-0x20(%rbp)
je     11ab <getnum+0x6b>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    1210 <getnum+0xd0>
lea    -0x50(%rbp),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1030 <fgets@plt>
cmp    $0x0,%eax
jne    11d2 <getnum+0x92>
xor    %edi,%edi
call   1060 <exit@plt>
movsbl -0x50(%rbp),%eax
cmp    $0x0,%eax
je     1209 <getnum+0xc9>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe25(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1040 <printerr@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
movsd  (%r14),%xmm0
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1040 <printerr@plt>
test   %rbx,%rbx
je     1173 <getnum+0x33>
movsd  (%rbx),%xmm0
movsd  %xmm0,(%r14)
jmp    11aa <getnum+0x6a>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x28,%esi
call   1030 <fgets@plt>
test   %eax,%eax
je     11c2 <getnum+0x82>
cmpb   $0x0,(%rsp)
je     11b8 <getnum+0x78>
lea    0xe79(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
movsd  (%r14),%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1040 <printerr@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%s = %.9E ? \00"
@.str.1 = [6 x i8] c"%.9E\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
define i32 @getnum(i8* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca double*
%7 = alloca double*
%8 = alloca [40 x i8]
store i8* %0, i8** %5
store double* %1, double** %6
store double* %2, double** %7
%9 = load i8*, i8** %5
%10 = load double*, double** %6
%11 = load double, double* %10
%12 = call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9, double %11)
%13 = load double*, double** %7
%14 = icmp ne double* %13, null
br i1 %14, label %15, label %22
15: ; preds = %3
%16 = load double*, double** %7
%17 = load double, double* %16
%18 = load double*, double** %6
store double %17, double* %18
%19 = load double*, double** %6
%20 = load double, double* %19
%21 = call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %20)
store i32 0, i32* %4
br label %42
22: ; preds = %3
%23 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i32 @fgets(i8* %23, i32 40, i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %22
%30 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %29
%35 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%36 = load double*, double** %6
%37 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %36)
%38 = load double*, double** %6
%39 = load double, double* %38
%40 = call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %39)
br label %41
41: ; preds = %34, %29
store i32 0, i32* %4
br label %42
42: ; preds = %41, %15
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s = %.9E ? \00"
@.str.1 = [6 x i8] c"%.9E\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%lf\00"
define i32 @getnum(i8* %0, double* %1, double* %2) {
%4 = alloca [40 x i8]
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%6 = load double, double* %1
%7 = tail call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, double %6)
%8 = icmp eq double* %2, null
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load double, double* %2
store double %10, double* %1
%11 = tail call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %25
12: ; preds = %3
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %5, i32 40, i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %12
%19 = load i8, i8* %5
%20 = icmp eq i8 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%23 = load double, double* %1
%24 = call i32 (i8*, ...) @printerr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %23)
br label %25
25: ; preds = %18, %21, %9
ret i32 0
}