#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ remove_leading_whitespace(char *);
char *strpbrk(char *, char *);
scalar_t__ strstr(char *, char *);
double strtod(char *, int /*<<< orphan*/ *);
void find_match_double_hex(char *buffer, char *match, double *result) {
  char *position;
  remove_leading_whitespace(buffer);
  if (strstr(buffer, match) == strstr(buffer, buffer)) {
    position = strpbrk(buffer, ":=");
    if (position != NULL) {
      memcpy(position, "0x", 2);
      *result = strtod(position, NULL);
    } else
      *result = 0;
  }
}


x86 assembly (clang, -O0):
<find_match_double_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <remove_leading_whitespace@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jne    11f9 <find_match_double_hex+0xa9>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e9 <find_match_double_hex+0x99>
mov    -0x20(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x2,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11f4 <find_match_double_hex+0xa4>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11f9 <find_match_double_hex+0xa9>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_match_double_hex>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1070 <remove_leading_whitespace@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
cmp    %rax,%r15
jne    11c0 <find_match_double_hex+0x70>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strpbrk@plt>
test   %rax,%rax
je     11b8 <find_match_double_hex+0x68>
mov    %rax,%rbx
lea    0xe64(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
jmp    11bb <find_match_double_hex+0x6b>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c":=\00"
@.str.1 = [3 x i8] c"0x\00"
define void @find_match_double_hex(i8* %0, i8* %1, double* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store double* %2, double** %6
%8 = load i8*, i8** %4
%9 = call i32 @remove_leading_whitespace(i8* %8)
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i64 @strstr(i8* %10, i8* %11)
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i64 @strstr(i8* %13, i8* %14)
%16 = icmp eq i64 %12, %15
br i1 %16, label %17, label %31
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = call i8* @strpbrk(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = call i32 @memcpy(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%25 = load i8*, i8** %7
%26 = call double @strtod(i8* %25, i32* null)
%27 = load double*, double** %6
store double %26, double* %27
br label %30
28: ; preds = %17
%29 = load double*, double** %6
store double 0.000000e+00, double* %29
br label %30
30: ; preds = %28, %22
br label %31
31: ; preds = %30, %3
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c":=\00"
@.str.1 = [3 x i8] c"0x\00"
define void @find_match_double_hex(i8* %0, i8* %1, double* nocapture writeonly %2) {
%4 = tail call i32 @remove_leading_whitespace(i8* %0)
%5 = tail call i64 @strstr(i8* %0, i8* %1)
%6 = tail call i64 @strstr(i8* %0, i8* %0)
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @memcpy(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%13 = tail call double @strtod(i8* nocapture %9, i32* null)
br label %14
14: ; preds = %8, %11
%15 = phi double [ %13, %11 ], [ 0.000000e+00, %8 ]
store double %15, double* %2
br label %16
16: ; preds = %14, %3
ret void
}