#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 */
int /*<<< orphan*/ printf(char *, char *, int, double);
double strtod(char *, int /*<<< orphan*/ *);
int main(void) {
  char ns[] = "1234.5678", nns[] = "-1234.5678";
  double x, xx;
  x = strtod(ns, NULL);
  xx = strtod(nns, NULL);
  printf("x:\n\t%s - %d = %.4f\n", ns, (int)x, x - (int)x);
  printf("xx:\n\t%s - %d = %.4f\n", nns, (int)xx, xx - (int)xx);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xec8(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xeb1(%rip),%ax
mov    %ax,-0x11(%rbp)
mov    0xea9(%rip),%al
mov    %al,-0xf(%rbp)
lea    -0xe(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
lea    -0x19(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
lea    -0xe(%rbp),%rsi
cvttsd2si -0x28(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
cvttsd2si -0x28(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
lea    -0x19(%rbp),%rsi
cvttsd2si -0x30(%rbp),%edx
movsd  -0x30(%rbp),%xmm0
cvttsd2si -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movabs $0x3736352e34333231,%rax
35 36 37
mov    %rax,(%rsp)
movw   $0x38,0x8(%rsp)
movabs $0x36352e343332312d,%rax
2e 35 36
mov    %rax,0x10(%rsp)
movl   $0x383736,0x17(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movaps %xmm0,0x20(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movapd 0x20(%rsp),%xmm2
cvttsd2si %xmm2,%edx
cvttpd2dq %xmm2,%xmm1
movaps %xmm0,0x30(%rsp)
cvtdq2pd %xmm1,%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
movapd 0x30(%rsp),%xmm1
cvttsd2si %xmm1,%edx
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xe48(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.ns = [10 x i8] c"1234.5678\00"
@__const.main.nns = [11 x i8] c"-1234.5678\00"
@.str = [20 x i8] c"x:\0A\09%s - %d = %.4f\0A\00"
@.str.1 = [21 x i8] c"xx:\0A\09%s - %d = %.4f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [11 x i8]
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = bitcast [10 x i8]* %2 to i8*
%7 = bitcast [11 x i8]* %3 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call double @strtod(i8* %8, i32* null)
store double %9, double* %4
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%11 = call double @strtod(i8* %10, i32* null)
store double %11, double* %5
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = load double, double* %4
%14 = fptosi double %13 to i32
%15 = load double, double* %4
%16 = load double, double* %4
%17 = fptosi double %16 to i32
%18 = sitofp i32 %17 to double
%19 = fsub double %15, %18
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %14, double %19)
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%22 = load double, double* %5
%23 = fptosi double %22 to i32
%24 = load double, double* %5
%25 = load double, double* %5
%26 = fptosi double %25 to i32
%27 = sitofp i32 %26 to double
%28 = fsub double %24, %27
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %23, double %28)
ret i32 0
}

LLVM IR (-O2):
@__const.main.ns = [10 x i8] c"1234.5678\00"
@__const.main.nns = [11 x i8] c"-1234.5678\00"
@.str = [20 x i8] c"x:\0A\09%s - %d = %.4f\0A\00"
@.str.1 = [21 x i8] c"xx:\0A\09%s - %d = %.4f\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = call double @strtod(i8* nocapture %3, i32* null)
%6 = call double @strtod(i8* nocapture %4, i32* null)
%7 = fptosi double %5 to i32
%8 = sitofp i32 %7 to double
%9 = fsub double %5, %8
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %7, double %9)
%11 = fptosi double %6 to i32
%12 = sitofp i32 %11 to double
%13 = fsub double %6, %12
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %11, double %13)
ret i32 0
}