#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 */
scalar_t__ atof(char *);
double fabs(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, double);
int /*<<< orphan*/ strcpy(char *, char *);
int wsys_decimal_is_period(void) {
  double x;
  char buf[16];
  x = 12.34;
  sprintf(buf, "%5.2f", x);
  if (buf[2] != '.')
    return (0);
  strcpy(buf, "12.34");
  return (fabs(atof(buf) - x) < .01);
}


x86 assembly (clang, -O0):
<wsys_decimal_is_period>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xeab(%rip),%rsi
call   1060 <sprintf@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x2e,%eax
je     1183 <wsys_decimal_is_period+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11ca <wsys_decimal_is_period+0x8a>
lea    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1040 <atof@plt>
cvtsi2sd %rax,%xmm0
subsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wsys_decimal_is_period>:
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rsi
mov    %rsp,%rdi
movsd  0xea9(%rip),%xmm0
call   1060 <sprintf@plt>
xor    %eax,%eax
cmpb   $0x2e,0x2(%rsp)
jne    11aa <wsys_decimal_is_period+0x6a>
lea    0xeb2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe79(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <fabs@plt>
movsd  0xe6f(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%5.2f\00"
@.str.1 = [6 x i8] c"12.34\00"
define i32 @wsys_decimal_is_period() {
%1 = alloca i32
%2 = alloca double
%3 = alloca [16 x i8]
store double 1.234000e+01, double* %2
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = load double, double* %2
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %5)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 46
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 0, i32* %1
br label %24
12: ; preds = %0
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%16 = call i64 @atof(i8* %15)
%17 = sitofp i64 %16 to double
%18 = load double, double* %2
%19 = fsub double %17, %18
%20 = fptosi double %19 to i64
%21 = call double @fabs(i64 %20)
%22 = fcmp olt double %21, 1.000000e-02
%23 = zext i1 %22 to i32
store i32 %23, i32* %1
br label %24
24: ; preds = %12, %11
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [6 x i8] c"%5.2f\00"
@.str.1 = [6 x i8] c"12.34\00"
define i32 @wsys_decimal_is_period() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double 1.234000e+01)
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 46
br i1 %6, label %7, label %16
7: ; preds = %0
%8 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = call i64 @atof(i8* %2)
%10 = sitofp i64 %9 to double
%11 = fadd double %10, -1.234000e+01
%12 = fptosi double %11 to i64
%13 = call double @fabs(i64 %12)
%14 = fcmp olt double %13, 1.000000e-02
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %0, %7
%17 = phi i32 [ %15, %7 ], [ 0, %0 ]
ret i32 %17
}