#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 */
char *d_s(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
double str2num(char *);
int main() {
  char *s;
  double x;
  double y = 1234.5678;
  printf("Enter a string that's in the same format of a number (e.g. "
         "'1234.5678'): ");
  s = d_s(s);
  x = str2num(s);
  printf("%.4lf - %s = [%.4lf]\n", y, s, y - x);
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <d_s@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <str2num@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rsi
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
lea    0xeb3(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
call   1050 <d_s@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <str2num@plt>
movsd  0xe99(%rip),%xmm2
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
lea    0xedc(%rip),%rdi
movapd %xmm2,%xmm0
mov    %rbx,%rsi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [74 x i8] c"Enter a string that's in the same format of a number (e.g. '1234.5678'): \00"
@.str.1 = [22 x i8] c"%.4lf - %s = [%.4lf]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0x40934A456D5CFAAD, double* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i8* @d_s(i8* %6)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call double @str2num(i8* %8)
store double %9, double* %3
%10 = load double, double* %4
%11 = load i8*, i8** %2
%12 = load double, double* %4
%13 = load double, double* %3
%14 = fsub double %12, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %10, i8* %11, double %14)
%16 = load i8*, i8** %2
%17 = call i32 @free(i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [74 x i8] c"Enter a string that's in the same format of a number (e.g. '1234.5678'): \00"
@.str.1 = [22 x i8] c"%.4lf - %s = [%.4lf]\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @d_s(i8* undef)
%3 = tail call double @str2num(i8* %2)
%4 = fsub double 0x40934A456D5CFAAD, %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double 0x40934A456D5CFAAD, i8* %2, double %4)
%6 = tail call i32 @free(i8* %2)
ret i32 0
}