#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 */
double strtod(char const *, char **);
int validate_coord(const char *s) {
  char *end = 0;
  double d;
  if (!s)
    return 0;
  d = strtod(s, &end);
  if (end == s)
    return 0;
  if (d < 0.0 || 1.0 < d)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<validate_coord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113b <validate_coord+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    119f <validate_coord+0x8f>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1167 <validate_coord+0x57>
movl   $0x0,-0x4(%rbp)
jmp    119f <validate_coord+0x8f>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     118c <validate_coord+0x7c>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1198 <validate_coord+0x88>
movl   $0x0,-0x4(%rbp)
jmp    119f <validate_coord+0x8f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_coord>:
push   %rbp
push   %rbx
push   %rax
movq   $0x0,(%rsp)
xor    %ebp,%ebp
test   %rdi,%rdi
je     114e <validate_coord+0x3e>
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1030 <strtod@plt>
cmp    %rbx,(%rsp)
je     114e <validate_coord+0x3e>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
setbe  %al
ucomisd 0xeba(%rip),%xmm0
setbe  %cl
and    %al,%cl
movzbl %cl,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @validate_coord(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
store i8* %0, i8** %3
store i8* null, i8** %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call double @strtod(i8* %10, i8** %4)
store double %11, double* %5
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = icmp eq i8* %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 0, i32* %2
br label %24
16: ; preds = %9
%17 = load double, double* %5
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load double, double* %5
%21 = fcmp olt double 1.000000e+00, %20
br i1 %21, label %22, label %23
22: ; preds = %19, %16
store i32 0, i32* %2
br label %24
23: ; preds = %19
store i32 1, i32* %2
br label %24
24: ; preds = %23, %22, %15, %8
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @validate_coord(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = icmp eq i8* %0, null
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = call double @strtod(i8* %0, i8** %2)
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, %0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = fcmp uge double %6, 0.000000e+00
%11 = fcmp ule double %6, 1.000000e+00
%12 = and i1 %10, %11
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %5, %1
%15 = phi i32 [ 0, %1 ], [ 0, %5 ], [ %13, %9 ]
ret i32 %15
}