#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 mjson_find(char const *, int, char const *, char const **, int *);
double mystrtod(char const *, int /*<<< orphan*/ *);
int mjson_get_number(const char *s, int len, const char *path, double *v) {
  const char *p;
  int tok, n;
  if ((tok = mjson_find(s, len, path, &p, &n)) == 12) {
    if (v != NULL)
      *v = mystrtod(p, NULL);
  }
  return tok == 12 ? 1 : 0;
}


x86 assembly (clang, -O0):
<mjson_get_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <mjson_find@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xc,%eax
jne    1180 <mjson_get_number+0x60>
cmpq   $0x0,-0x20(%rbp)
je     117b <mjson_get_number+0x5b>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <mystrtod@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1180 <mjson_get_number+0x60>
mov    -0x2c(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0xc,%edx
cmove  %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mjson_get_number>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
lea    0x8(%rsp),%rcx
lea    0x14(%rsp),%r8
call   1040 <mjson_find@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     1154 <mjson_get_number+0x34>
cmp    $0xc,%ebp
jne    1154 <mjson_get_number+0x34>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <mystrtod@plt>
movsd  %xmm0,(%rbx)
xor    %eax,%eax
cmp    $0xc,%ebp
sete   %al
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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