int CallbackOnJsonNode(int type, char *jpath, int jpath_len, int jpath_size,
                       char *nodename, int nodename_len, char *content,
                       int content_len, void *p) {
  if (type & 0x10) {
    if (type & 0x01) {
      printf("ENTER-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\n", (char *)p,
             jpath_len, jpath, nodename_len, nodename);
    } else if (type & 0x02) {
      printf("LEAVE-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\n", (char *)p,
             jpath_len, jpath, nodename_len, nodename);
    }
  } else if (type & 0x40) {
    if (type & 0x01) {
      printf("ENTER-ARRAY  p[%s] jpath[%.*s] nodename[%.*s]\n", (char *)p,
             jpath_len, jpath, nodename_len, nodename);
    } else if (type & 0x02) {
      printf("LEAVE-ARRAY  p[%s] jpath[%.*s] nodename[%.*s]\n", (char *)p,
             jpath_len, jpath, nodename_len, nodename);
    }
  } else if (type & 0x20) {
    printf("LEAF         p[%s] jpath[%.*s] nodename[%.*s] content[%.*s]\n",
           (char *)p, jpath_len, jpath, nodename_len, nodename, content_len,
           content);
  }
  return 0;
}


x86 assembly (clang, -O0):
<CallbackOnJsonNode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11b6 <CallbackOnJsonNode+0xa6>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117c <CallbackOnJsonNode+0x6c>
mov    0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <CallbackOnJsonNode+0xa1>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11ac <CallbackOnJsonNode+0x9c>
mov    0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <CallbackOnJsonNode+0xa1>
jmp    127f <CallbackOnJsonNode+0x16f>
mov    -0x4(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1234 <CallbackOnJsonNode+0x124>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11fa <CallbackOnJsonNode+0xea>
mov    0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122f <CallbackOnJsonNode+0x11f>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     122a <CallbackOnJsonNode+0x11a>
mov    0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122f <CallbackOnJsonNode+0x11f>
jmp    127a <CallbackOnJsonNode+0x16a>
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1275 <CallbackOnJsonNode+0x165>
mov    0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    0x18(%rbp),%r10d
mov    0x10(%rbp),%rax
lea    0xe57(%rip),%rdi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <CallbackOnJsonNode+0x16a>
jmp    127f <CallbackOnJsonNode+0x16f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CallbackOnJsonNode>:
push   %rax
mov    %r8,%rax
mov    %rsi,%rcx
mov    0x20(%rsp),%rsi
test   $0x10,%dil
jne    1153 <CallbackOnJsonNode+0x43>
test   $0x40,%dil
jne    1168 <CallbackOnJsonNode+0x58>
test   $0x20,%dil
je     119a <CallbackOnJsonNode+0x8a>
mov    0x18(%rsp),%r10d
lea    0xf82(%rip),%rdi
mov    %r9d,%r8d
mov    %rax,%r9
xor    %eax,%eax
push   0x10(%rsp)
push   %r10
call   1030 <printf@plt>
add    $0x10,%rsp
jmp    119a <CallbackOnJsonNode+0x8a>
test   $0x1,%dil
jne    117d <CallbackOnJsonNode+0x6d>
test   $0x2,%dil
je     119a <CallbackOnJsonNode+0x8a>
lea    0xec9(%rip),%rdi
jmp    118d <CallbackOnJsonNode+0x7d>
test   $0x1,%dil
jne    1186 <CallbackOnJsonNode+0x76>
test   $0x2,%dil
je     119a <CallbackOnJsonNode+0x8a>
lea    0xf12(%rip),%rdi
jmp    118d <CallbackOnJsonNode+0x7d>
lea    0xe7c(%rip),%rdi
jmp    118d <CallbackOnJsonNode+0x7d>
lea    0xed1(%rip),%rdi
mov    %r9d,%r8d
mov    %rax,%r9
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"ENTER-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.1 = [47 x i8] c"LEAVE-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.2 = [47 x i8] c"ENTER-ARRAY p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.3 = [47 x i8] c"LEAVE-ARRAY p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.4 = [61 x i8] c"LEAF p[%s] jpath[%.*s] nodename[%.*s] content[%.*s]\0A\00"
define i32 @CallbackOnJsonNode(i32 %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5, i8* %6, i32 %7, i8* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i8*
store i32 %0, i32* %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i8* %4, i8** %14
store i32 %5, i32* %15
store i8* %6, i8** %16
store i32 %7, i32* %17
store i8* %8, i8** %18
%19 = load i32, i32* %10
%20 = and i32 %19, 16
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %9
%23 = load i32, i32* %10
%24 = and i32 %23, 1
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = load i8*, i8** %18
%28 = load i32, i32* %12
%29 = load i8*, i8** %11
%30 = load i32, i32* %15
%31 = load i8*, i8** %14
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %28, i8* %29, i32 %30, i8* %31)
br label %45
33: ; preds = %22
%34 = load i32, i32* %10
%35 = and i32 %34, 2
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i8*, i8** %18
%39 = load i32, i32* %12
%40 = load i8*, i8** %11
%41 = load i32, i32* %15
%42 = load i8*, i8** %14
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %38, i32 %39, i8* %40, i32 %41, i8* %42)
br label %44
44: ; preds = %37, %33
br label %45
45: ; preds = %44, %26
br label %89
46: ; preds = %9
%47 = load i32, i32* %10
%48 = and i32 %47, 64
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %74
50: ; preds = %46
%51 = load i32, i32* %10
%52 = and i32 %51, 1
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load i8*, i8** %18
%56 = load i32, i32* %12
%57 = load i8*, i8** %11
%58 = load i32, i32* %15
%59 = load i8*, i8** %14
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %55, i32 %56, i8* %57, i32 %58, i8* %59)
br label %73
61: ; preds = %50
%62 = load i32, i32* %10
%63 = and i32 %62, 2
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %61
%66 = load i8*, i8** %18
%67 = load i32, i32* %12
%68 = load i8*, i8** %11
%69 = load i32, i32* %15
%70 = load i8*, i8** %14
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %66, i32 %67, i8* %68, i32 %69, i8* %70)
br label %72
72: ; preds = %65, %61
br label %73
73: ; preds = %72, %54
br label %88
74: ; preds = %46
%75 = load i32, i32* %10
%76 = and i32 %75, 32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %87
78: ; preds = %74
%79 = load i8*, i8** %18
%80 = load i32, i32* %12
%81 = load i8*, i8** %11
%82 = load i32, i32* %15
%83 = load i8*, i8** %14
%84 = load i32, i32* %17
%85 = load i8*, i8** %16
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %79, i32 %80, i8* %81, i32 %82, i8* %83, i32 %84, i8* %85)
br label %87
87: ; preds = %78, %74
br label %88
88: ; preds = %87, %73
br label %89
89: ; preds = %88, %45
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"ENTER-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.1 = [47 x i8] c"LEAVE-BRANCH p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.2 = [47 x i8] c"ENTER-ARRAY p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.3 = [47 x i8] c"LEAVE-ARRAY p[%s] jpath[%.*s] nodename[%.*s]\0A\00"
@.str.4 = [61 x i8] c"LEAF p[%s] jpath[%.*s] nodename[%.*s] content[%.*s]\0A\00"
define i32 @CallbackOnJsonNode(i32 %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5, i8* %6, i32 %7, i8* %8) {
%10 = and i32 %0, 16
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = and i32 %0, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %2, i8* %1, i32 %5, i8* %4)
br label %40
17: ; preds = %12
%18 = and i32 %0, 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %40, label %20
20: ; preds = %17
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 %2, i8* %1, i32 %5, i8* %4)
br label %40
22: ; preds = %9
%23 = and i32 %0, 64
%24 = icmp eq i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %22
%26 = and i32 %0, 1
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 %2, i8* %1, i32 %5, i8* %4)
br label %40
30: ; preds = %25
%31 = and i32 %0, 2
%32 = icmp eq i32 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %30
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %2, i8* %1, i32 %5, i8* %4)
br label %40
35: ; preds = %22
%36 = and i32 %0, 32
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0), i8* %8, i32 %2, i8* %1, i32 %5, i8* %4, i32 %7, i8* %6)
br label %40
40: ; preds = %30, %33, %28, %38, %35, %15, %20, %17
ret i32 0
}