new_float(name, value) char *name;
double *value;
{
  int done;
  int flag;
  double newz;
  char tvalue[200];
  sprintf(tvalue, "%.16g", *value);
  done = new_string(name, tvalue);
  if (done == 0 || strlen(tvalue) == 0)
    return -1;
  if (tvalue[0] == '%') {
    flag = do_calc(&tvalue[1], &newz);
    if (flag != -1)
      *value = newz;
    return (0);
  }
  *value = atof(tvalue);
  return (0);
}


x86 assembly (clang, -O0):
<new_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe87(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x0,%al
call   1060 <new_string@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b5 <new_float+0x65>
lea    -0xf0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    11c1 <new_float+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <new_float+0xde>
movsbl -0xf0(%rbp),%eax
cmp    $0x25,%eax
jne    120d <new_float+0xbd>
lea    -0xf0(%rbp),%rdi
add    $0x1,%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <do_calc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     1201 <new_float+0xb1>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    122e <new_float+0xde>
lea    -0xf0(%rbp),%rdi
mov    $0x0,%al
call   1030 <atof@plt>
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_float>:
push   %rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
movsd  (%rsi),%xmm0
lea    0xea4(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <new_string@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     11c7 <new_float+0x87>
mov    0x10(%rsp),%al
test   %al,%al
je     11c7 <new_float+0x87>
cmp    $0x25,%al
jne    11ad <new_float+0x6d>
lea    0x11(%rsp),%rdi
xor    %ebp,%ebp
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <do_calc@plt>
cmp    $0xffffffff,%eax
je     11c7 <new_float+0x87>
movsd  0x8(%rsp),%xmm0
jmp    11c0 <new_float+0x80>
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1030 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.16g\00"
define i32 @new_float(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca [200 x i8]
store i8* %0, i8** %4
store double* %1, double** %5
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%11 = load double*, double** %5
%12 = load double, double* %11
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %12)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%16 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @new_string to i32 (i8*, i8*, ...)*)(i8* %14, i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %2
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%21 = call i64 @strlen(i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19, %2
store i32 -1, i32* %3
br label %43
24: ; preds = %19
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 37
br i1 %28, label %29, label %38
29: ; preds = %24
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 1
%31 = call i32 (i8*, double*, ...) bitcast (i32 (...)* @do_calc to i32 (i8*, double*, ...)*)(i8* %30, double* %8)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load double, double* %8
%36 = load double*, double** %5
store double %35, double* %36
br label %37
37: ; preds = %34, %29
store i32 0, i32* %3
br label %43
38: ; preds = %24
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %39)
%41 = sitofp i32 %40 to double
%42 = load double*, double** %5
store double %41, double* %42
store i32 0, i32* %3
br label %43
43: ; preds = %38, %37, %23
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.16g\00"
define i32 @new_float(i8* %0, double* nocapture %1) {
%3 = alloca double
%4 = alloca [200 x i8]
%5 = bitcast double* %3 to i8*
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = load double, double* %1
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %7)
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @new_string to i32 (i8*, i8*, ...)*)(i8* %0, i8* %6)
%10 = icmp eq i32 %9, 0
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 0
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %27, label %14
14: ; preds = %2
%15 = icmp eq i8 %11, 37
br i1 %15, label %16, label %22
16: ; preds = %14
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 1
%18 = call i32 (i8*, double*, ...) bitcast (i32 (...)* @do_calc to i32 (i8*, double*, ...)*)(i8* %17, double* %3)
%19 = icmp eq i32 %18, -1
br i1 %19, label %27, label %20
20: ; preds = %16
%21 = load double, double* %3
br label %25
22: ; preds = %14
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %6)
%24 = sitofp i32 %23 to double
br label %25
25: ; preds = %22, %20
%26 = phi double [ %21, %20 ], [ %24, %22 ]
store double %26, double* %1
br label %27
27: ; preds = %25, %16, %2
%28 = phi i32 [ -1, %2 ], [ 0, %16 ], [ 0, %25 ]
ret i32 %28
}