#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 *, char **);
bool match_double(char **p, void *f64) {
  char *str_end;
  double x = strtod(*p, &str_end);
  if (f64)
    *((double *)f64) = x;
  return (str_end != *p) && (*p = str_end);
}


x86 assembly (clang, -O0):
<match_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114d <match_double+0x3d>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
mov    %al,-0x21(%rbp)
je     1178 <match_double+0x68>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_double>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    %rsp,%rsi
call   1030 <strtod@plt>
test   %r14,%r14
je     112f <match_double+0x1f>
movsd  %xmm0,(%r14)
mov    (%rsp),%rcx
cmp    (%rbx),%rcx
je     1145 <match_double+0x35>
mov    %rcx,(%rbx)
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    1147 <match_double+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @match_double(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
store i8** %0, i8*** %3
store i8* %1, i8** %4
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
%9 = call double @strtod(i8* %8, i8** %5)
store double %9, double* %6
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load double, double* %6
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to double*
store double %13, double* %15
br label %16
16: ; preds = %12, %2
%17 = load i8*, i8** %5
%18 = load i8**, i8*** %3
%19 = load i8*, i8** %18
%20 = icmp ne i8* %17, %19
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = load i8**, i8*** %3
store i8* %22, i8** %23
%24 = icmp ne i8* %22, null
br label %25
25: ; preds = %21, %16
%26 = phi i1 [ false, %16 ], [ %24, %21 ]
%27 = zext i1 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
define i32 @match_double(i8** nocapture %0, i8* writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i8*, i8** %0
%6 = call double @strtod(i8* %5, i8** %3)
%7 = icmp eq i8* %1, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = bitcast i8* %1 to double*
store double %6, double* %9
br label %10
10: ; preds = %8, %2
%11 = load i8*, i8** %3
%12 = load i8*, i8** %0
%13 = icmp eq i8* %11, %12
br i1 %13, label %17, label %14
14: ; preds = %10
store i8* %11, i8** %0
%15 = icmp ne i8* %11, null
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %14, %10
%18 = phi i32 [ 0, %10 ], [ %16, %14 ]
ret i32 %18
}