getnum(str, pd) char *str;
double *pd;
{
  char s[40];
  printf("%s (%.10e) ? ", str, *pd);
  gets(s);
  if (s[0] != '\0') {
    sscanf(s, "%lf", pd);
    printf("%.10e\n", *pd);
  }
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%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    -0x18(%rbp),%rdx
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%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    0xeaa(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
movsd  (%rbx),%xmm0
lea    0xe96(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"%s (%.10e) ? \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.10e\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 ([14 x i8], [14 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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %14
14: ; preds = %10, %2
ret i32 undef
}