int getnum(line, val)
char *line;
double *val;
{
  char s[40];
  printf("%s = %.9E ? ", line, *val);
  gets(s);
  if (s[0] != '\0') {
    sscanf(s, "%lf", val);
    printf("%.9E\n", *val);
  }
  return 0;
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xead(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1040 <gets@plt>
movsbl -0x40(%rbp),%eax
cmp    $0x0,%eax
je     119e <getnum+0x6e>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
movsd  (%rbx),%xmm0
lea    0xeba(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <gets@plt>
cmpb   $0x0,(%rsp)
je     1183 <getnum+0x53>
lea    0xea9(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
movsd  (%rbx),%xmm0
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s = %.9E ? \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [6 x i8] c"%.9E\0A\00"
define i32 @getnum(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca [40 x i8]
store i8* %0, i8** %3
store double* %1, double** %4
%6 = load i8*, i8** %3
%7 = load double*, double** %4
%8 = load double, double* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6, double %8)
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %10)
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%18 = load double*, double** %4
%19 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %18)
%20 = load double*, double** %4
%21 = load double, double* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %23
23: ; preds = %16, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s = %.9E ? \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [6 x i8] c"%.9E\0A\00"
define i32 @getnum(i8* %0, double* %1) {
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%5 = load double, double* %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, double %5)
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %4)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = call i32 (i8*, i8*, ...) @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%12 = load double, double* %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %14
14: ; preds = %10, %2
ret i32 0
}