#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *strchr(char *, char);
char *strstr(char *, char *);
unsigned int JsonGetProp(char *buf, char *tag) {
  char cmd_buf[256];
  char nstr[32];
  char *ptmp = NULL, *pend = NULL, *pstart = NULL;
  if ((NULL == buf) || (NULL == tag)) {
    return -1;
  }
  bzero(cmd_buf, 256);
  memcpy(cmd_buf, buf, 256);
  ptmp = strstr(cmd_buf, tag);
  if (NULL == ptmp) {
    return -1;
  }
  ptmp = strchr(ptmp, ':');
  if (NULL == ptmp) {
    return -1;
  }
  ptmp = strchr(ptmp, '\"');
  if (NULL == ptmp) {
    return -1;
  }
  pstart = ptmp + 1;
  if (NULL == pstart) {
    return -1;
  }
  pend = strchr(pstart, '\"');
  if (NULL == pend) {
    return -1;
  }
  bzero(nstr, 32);
  memcpy(nstr, pstart, pend - pstart);
  return atoi(nstr);
}


x86 assembly (clang, -O0):
<JsonGetProp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x148(%rbp)
movq   $0x0,-0x150(%rbp)
movq   $0x0,-0x158(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     119c <JsonGetProp+0x4c>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11a8 <JsonGetProp+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   1050 <bzero@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1040 <memcpy@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x148(%rbp)
xor    %eax,%eax
cmp    -0x148(%rbp),%rax
jne    1200 <JsonGetProp+0xb0>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
mov    -0x148(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x148(%rbp)
xor    %eax,%eax
cmp    -0x148(%rbp),%rax
jne    1233 <JsonGetProp+0xe3>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
mov    -0x148(%rbp),%rdi
mov    $0x22,%esi
call   1030 <strchr@plt>
mov    %rax,-0x148(%rbp)
xor    %eax,%eax
cmp    -0x148(%rbp),%rax
jne    1266 <JsonGetProp+0x116>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
mov    -0x148(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x158(%rbp)
xor    %eax,%eax
cmp    -0x158(%rbp),%rax
jne    1293 <JsonGetProp+0x143>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
mov    -0x158(%rbp),%rdi
mov    $0x22,%esi
call   1030 <strchr@plt>
mov    %rax,-0x150(%rbp)
xor    %eax,%eax
cmp    -0x150(%rbp),%rax
jne    12c6 <JsonGetProp+0x176>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <JsonGetProp+0x1bc>
lea    -0x140(%rbp),%rdi
mov    $0x20,%esi
call   1050 <bzero@plt>
lea    -0x140(%rbp),%rdi
mov    -0x158(%rbp),%rsi
mov    -0x150(%rbp),%rax
mov    -0x158(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
lea    -0x140(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JsonGetProp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    $0xffffffff,%r15d
test   %rdi,%rdi
je     1218 <JsonGetProp+0xc8>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1218 <JsonGetProp+0xc8>
mov    %rdi,%rbp
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1050 <bzero@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x100,%edx
call   1040 <memcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     1218 <JsonGetProp+0xc8>
mov    %rax,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1218 <JsonGetProp+0xc8>
mov    %rax,%rdi
mov    $0x22,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1218 <JsonGetProp+0xc8>
mov    %rax,%r14
add    $0x1,%r14
mov    %r14,%rdi
mov    $0x22,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1218 <JsonGetProp+0xc8>
mov    %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1050 <bzero@plt>
sub    %r14d,%ebx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
mov    %rbp,%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
mov    %r15d,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @JsonGetProp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca [32 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
%11 = load i8*, i8** %4
%12 = icmp eq i8* null, %11
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %17
16: ; preds = %13, %2
store i32 -1, i32* %3
br label %67
17: ; preds = %13
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = call i32 @bzero(i8* %18, i32 256)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i32 @memcpy(i8* %20, i8* %21, i32 256)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %5
%25 = call i8* @strstr(i8* %23, i8* %24)
store i8* %25, i8** %8
%26 = load i8*, i8** %8
%27 = icmp eq i8* null, %26
br i1 %27, label %28, label %29
28: ; preds = %17
store i32 -1, i32* %3
br label %67
29: ; preds = %17
%30 = load i8*, i8** %8
%31 = call i8* @strchr(i8* %30, i8 signext 58)
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = icmp eq i8* null, %32
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 -1, i32* %3
br label %67
35: ; preds = %29
%36 = load i8*, i8** %8
%37 = call i8* @strchr(i8* %36, i8 signext 34)
store i8* %37, i8** %8
%38 = load i8*, i8** %8
%39 = icmp eq i8* null, %38
br i1 %39, label %40, label %41
40: ; preds = %35
store i32 -1, i32* %3
br label %67
41: ; preds = %35
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8* %43, i8** %10
%44 = load i8*, i8** %10
%45 = icmp eq i8* null, %44
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 -1, i32* %3
br label %67
47: ; preds = %41
%48 = load i8*, i8** %10
%49 = call i8* @strchr(i8* %48, i8 signext 34)
store i8* %49, i8** %9
%50 = load i8*, i8** %9
%51 = icmp eq i8* null, %50
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 -1, i32* %3
br label %67
53: ; preds = %47
%54 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%55 = call i32 @bzero(i8* %54, i32 32)
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%57 = load i8*, i8** %10
%58 = load i8*, i8** %9
%59 = load i8*, i8** %10
%60 = ptrtoint i8* %58 to i64
%61 = ptrtoint i8* %59 to i64
%62 = sub i64 %60, %61
%63 = trunc i64 %62 to i32
%64 = call i32 @memcpy(i8* %56, i8* %57, i32 %63)
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%66 = call i32 @atoi(i8* %65)
store i32 %66, i32* %3
br label %67
67: ; preds = %53, %52, %46, %40, %34, %28, %16
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
define i32 @JsonGetProp(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = icmp eq i8* %0, null
%8 = icmp eq i8* %1, null
%9 = or i1 %7, %8
br i1 %9, label %33, label %10
10: ; preds = %2
%11 = call i32 @bzero(i8* %5, i32 256)
%12 = call i32 @memcpy(i8* %5, i8* %0, i32 256)
%13 = call i8* @strstr(i8* %5, i8* dereferenceable(1) %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %33, label %15
15: ; preds = %10
%16 = call i8* @strchr(i8* %13, i8 signext 58)
%17 = icmp eq i8* %16, null
br i1 %17, label %33, label %18
18: ; preds = %15
%19 = call i8* @strchr(i8* %16, i8 signext 34)
%20 = icmp eq i8* %19, null
br i1 %20, label %33, label %21
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %19, i64 1
%23 = call i8* @strchr(i8* %22, i8 signext 34)
%24 = icmp eq i8* %23, null
br i1 %24, label %33, label %25
25: ; preds = %21
%26 = call i32 @bzero(i8* %6, i32 32)
%27 = ptrtoint i8* %23 to i64
%28 = ptrtoint i8* %22 to i64
%29 = sub i64 %27, %28
%30 = trunc i64 %29 to i32
%31 = call i32 @memcpy(i8* %6, i8* %22, i32 %30)
%32 = call i32 @atoi(i8* %6)
br label %33
33: ; preds = %21, %18, %15, %10, %2, %25
%34 = phi i32 [ %32, %25 ], [ -1, %2 ], [ -1, %10 ], [ -1, %15 ], [ -1, %18 ], [ -1, %21 ]
ret i32 %34
}