#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 */
struct jsmnn {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *json_getstr(struct jsmnn *, char *);
scalar_t__ strcmp(char *, char *);
int json_parse_response(struct jsmnn *n) {
  char *resp;
  int rc;
  if (NULL == n)
    return (-1);
  if (NULL == (resp = json_getstr(n, "status")))
    return (-1);
  if (0 == strcmp(resp, "valid"))
    rc = 1;
  else if (0 == strcmp(resp, "pending"))
    rc = 0;
  else
    rc = -1;
  free(resp);
  return (rc);
}


x86 assembly (clang, -O0):
<json_parse_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1154 <json_parse_response+0x24>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <json_parse_response+0xc1>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1040 <json_getstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1182 <json_parse_response+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <json_parse_response+0xc1>
mov    -0x18(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <json_parse_response+0x7c>
movl   $0x1,-0x1c(%rbp)
jmp    11e2 <json_parse_response+0xb2>
mov    -0x18(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d6 <json_parse_response+0xa6>
movl   $0x0,-0x1c(%rbp)
jmp    11dd <json_parse_response+0xad>
movl   $0xffffffff,-0x1c(%rbp)
jmp    11e2 <json_parse_response+0xb2>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_parse_response>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1188 <json_parse_response+0x58>
lea    0xebc(%rip),%rsi
call   1040 <json_getstr@plt>
test   %rax,%rax
je     1188 <json_parse_response+0x58>
mov    %rax,%rbx
lea    0xeaf(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     117b <json_parse_response+0x4b>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
neg    %rax
sbb    %ebp,%ebp
jmp    1180 <json_parse_response+0x50>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.jsmnn = type { i32 }
@.str = [7 x i8] c"status\00"
@.str.1 = [6 x i8] c"valid\00"
@.str.2 = [8 x i8] c"pending\00"
define i32 @json_parse_response(%struct.jsmnn* %0) {
%2 = alloca i32
%3 = alloca %struct.jsmnn*
%4 = alloca i8*
%5 = alloca i32
store %struct.jsmnn* %0, %struct.jsmnn** %3
%6 = load %struct.jsmnn*, %struct.jsmnn** %3
%7 = icmp eq %struct.jsmnn* null, %6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %30
9: ; preds = %1
%10 = load %struct.jsmnn*, %struct.jsmnn** %3
%11 = call i8* @json_getstr(%struct.jsmnn* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %4
%12 = icmp eq i8* null, %11
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 -1, i32* %2
br label %30
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 0, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %5
br label %26
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 0, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 0, i32* %5
br label %25
24: ; preds = %19
store i32 -1, i32* %5
br label %25
25: ; preds = %24, %23
br label %26
26: ; preds = %25, %18
%27 = load i8*, i8** %4
%28 = call i32 @free(i8* %27)
%29 = load i32, i32* %5
store i32 %29, i32* %2
br label %30
30: ; preds = %26, %13, %8
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
%struct.jsmnn = type { i32 }
@.str = [7 x i8] c"status\00"
@.str.1 = [6 x i8] c"valid\00"
@.str.2 = [8 x i8] c"pending\00"
define i32 @json_parse_response(%struct.jsmnn* %0) {
%2 = icmp eq %struct.jsmnn* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i8* @json_getstr(%struct.jsmnn* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %6
%14 = phi i32 [ 1, %6 ], [ %12, %9 ]
%15 = tail call i32 @free(i8* %4)
br label %16
16: ; preds = %3, %1, %13
%17 = phi i32 [ %14, %13 ], [ -1, %1 ], [ -1, %3 ]
ret i32 %17
}