#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 */
typedef int uint_fast8_t;
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ scan_numeric(int /*<<< orphan*/ const **);
int /*<<< orphan*/ scan_text(int /*<<< orphan*/ const **);
void scan_value(const uint8_t **bufptr) {
  const uint8_t *ptr = *bufptr;
  uint_fast8_t ch;
  int depth;
  ch = *ptr++;
  switch (ch) {
  case 'n':
    ptr += 3;
    break;
  case 'f':
    ptr += 4;
    break;
  case 't':
    ptr += 3;
    break;
  case '"':
    scan_text(&ptr);
    break;
  case '[':
    depth = 1;
    while (depth > 0) {
      ch = *ptr++;
      switch (ch) {
      case '[':
        depth++;
        break;
      case ']':
        depth--;
        break;
      case '"':
        scan_text(&ptr);
        break;
      default:
        break;
      }
    }
    break;
  case '{':
    depth = 1;
    while (depth > 0) {
      ch = *ptr++;
      switch (ch) {
      case '{':
        depth++;
        break;
      case '}':
        depth--;
        break;
      case '"':
        scan_text(&ptr);
        break;
      default:
        break;
      }
    }
    break;
  default:
    ptr--;
    scan_numeric(&ptr);
    break;
  }
  *bufptr = ptr;
}


x86 assembly (clang, -O0):
<scan_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x22,%eax
je     11e7 <scan_value+0xc7>
jmp    115f <scan_value+0x3f>
mov    -0x1c(%rbp),%eax
sub    $0x5b,%eax
je     11f5 <scan_value+0xd5>
jmp    1170 <scan_value+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x66,%eax
je     11c5 <scan_value+0xa5>
jmp    1181 <scan_value+0x61>
mov    -0x1c(%rbp),%eax
sub    $0x6e,%eax
je     11b4 <scan_value+0x94>
jmp    1192 <scan_value+0x72>
mov    -0x1c(%rbp),%eax
sub    $0x74,%eax
je     11d6 <scan_value+0xb6>
jmp    11a3 <scan_value+0x83>
mov    -0x1c(%rbp),%eax
sub    $0x7b,%eax
je     1289 <scan_value+0x169>
jmp    131d <scan_value+0x1fd>
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x10(%rbp)
jmp    1332 <scan_value+0x212>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1332 <scan_value+0x212>
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x10(%rbp)
jmp    1332 <scan_value+0x212>
lea    -0x10(%rbp),%rdi
call   1030 <scan_text@plt>
jmp    1332 <scan_value+0x212>
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1284 <scan_value+0x164>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x22,%eax
je     126c <scan_value+0x14c>
jmp    122e <scan_value+0x10e>
mov    -0x20(%rbp),%eax
sub    $0x5b,%eax
je     1250 <scan_value+0x130>
jmp    123f <scan_value+0x11f>
mov    -0x20(%rbp),%eax
sub    $0x5d,%eax
je     125e <scan_value+0x13e>
jmp    127a <scan_value+0x15a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    127f <scan_value+0x15f>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    127f <scan_value+0x15f>
lea    -0x10(%rbp),%rdi
call   1030 <scan_text@plt>
jmp    127f <scan_value+0x15f>
jmp    127f <scan_value+0x15f>
jmp    11fc <scan_value+0xdc>
jmp    1332 <scan_value+0x212>
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1318 <scan_value+0x1f8>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x22,%eax
je     1300 <scan_value+0x1e0>
jmp    12c2 <scan_value+0x1a2>
mov    -0x24(%rbp),%eax
sub    $0x7b,%eax
je     12e4 <scan_value+0x1c4>
jmp    12d3 <scan_value+0x1b3>
mov    -0x24(%rbp),%eax
sub    $0x7d,%eax
je     12f2 <scan_value+0x1d2>
jmp    130e <scan_value+0x1ee>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1313 <scan_value+0x1f3>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1313 <scan_value+0x1f3>
lea    -0x10(%rbp),%rdi
call   1030 <scan_text@plt>
jmp    1313 <scan_value+0x1f3>
jmp    1313 <scan_value+0x1f3>
jmp    1290 <scan_value+0x170>
jmp    1332 <scan_value+0x212>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <scan_numeric@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_value>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    (%rdi),%rcx
lea    0x4(%rcx),%rax
mov    %rax,0x8(%rsp)
mov    (%rcx),%esi
lea    -0x5b(%rsi),%edx
cmp    $0x20,%edx
ja     1157 <scan_value+0x37>
lea    0xeb8(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
add    $0x10,%rcx
jmp    11d3 <scan_value+0xb3>
cmp    $0x22,%esi
jne    1168 <scan_value+0x48>
lea    0x8(%rsp),%rdi
call   1030 <scan_text@plt>
jmp    11d8 <scan_value+0xb8>
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <scan_numeric@plt>
jmp    11d8 <scan_value+0xb8>
mov    $0x1,%ebp
lea    0x8(%rsp),%rbx
jmp    119a <scan_value+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
je     11d8 <scan_value+0xb8>
mov    0x8(%rsp),%rax
lea    0x4(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rax),%eax
cmp    $0x22,%eax
je     11c0 <scan_value+0xa0>
cmp    $0x5d,%eax
je     1190 <scan_value+0x70>
cmp    $0x5b,%eax
jne    1195 <scan_value+0x75>
add    $0x1,%ebp
mov    0x8(%rsp),%rax
jmp    119a <scan_value+0x7a>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <scan_text@plt>
mov    0x8(%rsp),%rax
jmp    119a <scan_value+0x7a>
add    $0x14,%rcx
mov    %rcx,0x8(%rsp)
mov    0x8(%rsp),%rax
mov    %rax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%ebp
lea    0x8(%rsp),%rbx
jmp    120a <scan_value+0xea>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
je     11d8 <scan_value+0xb8>
mov    0x8(%rsp),%rax
lea    0x4(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rax),%eax
cmp    $0x22,%eax
je     1230 <scan_value+0x110>
cmp    $0x7d,%eax
je     1200 <scan_value+0xe0>
cmp    $0x7b,%eax
jne    1205 <scan_value+0xe5>
add    $0x1,%ebp
mov    0x8(%rsp),%rax
jmp    120a <scan_value+0xea>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <scan_text@plt>
mov    0x8(%rsp),%rax
jmp    120a <scan_value+0xea>

LLVM IR (-O0):
define void @scan_value(i32** %0) {
%2 = alloca i32**
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32** %0, i32*** %2
%6 = load i32**, i32*** %2
%7 = load i32*, i32** %6
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i32 1
store i32* %9, i32** %3
%10 = load i32, i32* %8
store i32 %10, i32* %4
%11 = load i32, i32* %4
switch i32 %11, label %63 [
i32 110, label %12
i32 102, label %15
i32 116, label %18
i32 34, label %21
i32 91, label %23
i32 123, label %43
]
12: ; preds = %1
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 3
store i32* %14, i32** %3
br label %67
15: ; preds = %1
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i64 4
store i32* %17, i32** %3
br label %67
18: ; preds = %1
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 3
store i32* %20, i32** %3
br label %67
21: ; preds = %1
%22 = call i32 @scan_text(i32** %3)
br label %67
23: ; preds = %1
store i32 1, i32* %5
br label %24
24: ; preds = %41, %23
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %3
%30 = load i32, i32* %28
store i32 %30, i32* %4
%31 = load i32, i32* %4
switch i32 %31, label %40 [
i32 91, label %32
i32 93, label %35
i32 34, label %38
]
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %41
35: ; preds = %27
%36 = load i32, i32* %5
%37 = add nsw i32 %36, -1
store i32 %37, i32* %5
br label %41
38: ; preds = %27
%39 = call i32 @scan_text(i32** %3)
br label %41
40: ; preds = %27
br label %41
41: ; preds = %40, %38, %35, %32
br label %24
42: ; preds = %24
br label %67
43: ; preds = %1
store i32 1, i32* %5
br label %44
44: ; preds = %61, %43
%45 = load i32, i32* %5
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %62
47: ; preds = %44
%48 = load i32*, i32** %3
%49 = getelementptr inbounds i32, i32* %48, i32 1
store i32* %49, i32** %3
%50 = load i32, i32* %48
store i32 %50, i32* %4
%51 = load i32, i32* %4
switch i32 %51, label %60 [
i32 123, label %52
i32 125, label %55
i32 34, label %58
]
52: ; preds = %47
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %61
55: ; preds = %47
%56 = load i32, i32* %5
%57 = add nsw i32 %56, -1
store i32 %57, i32* %5
br label %61
58: ; preds = %47
%59 = call i32 @scan_text(i32** %3)
br label %61
60: ; preds = %47
br label %61
61: ; preds = %60, %58, %55, %52
br label %44
62: ; preds = %44
br label %67
63: ; preds = %1
%64 = load i32*, i32** %3
%65 = getelementptr inbounds i32, i32* %64, i32 -1
store i32* %65, i32** %3
%66 = call i32 @scan_numeric(i32** %3)
br label %67
67: ; preds = %63, %62, %42, %21, %18, %15, %12
%68 = load i32*, i32** %3
%69 = load i32**, i32*** %2
store i32* %68, i32** %69
ret void
}

LLVM IR (-O2):
define void @scan_value(i32** nocapture %0) {
%2 = alloca i32*
%3 = bitcast i32** %2 to i8*
%4 = load i32*, i32** %0
%5 = getelementptr inbounds i32, i32* %4, i64 1
store i32* %5, i32** %2
%6 = load i32, i32* %4
switch i32 %6, label %45 [
i32 110, label %7
i32 102, label %9
i32 116, label %11
i32 34, label %13
i32 91, label %15
i32 123, label %30
]
7: ; preds = %1
%8 = getelementptr inbounds i32, i32* %4, i64 4
store i32* %8, i32** %2
br label %47
9: ; preds = %1
%10 = getelementptr inbounds i32, i32* %4, i64 5
store i32* %10, i32** %2
br label %47
11: ; preds = %1
%12 = getelementptr inbounds i32, i32* %4, i64 4
store i32* %12, i32** %2
br label %47
13: ; preds = %1
%14 = call i32 @scan_text(i32** %2)
br label %47
15: ; preds = %1, %27
%16 = phi i32* [ %29, %27 ], [ %5, %1 ]
%17 = phi i32 [ %28, %27 ], [ 1, %1 ]
%18 = getelementptr inbounds i32, i32* %16, i64 1
store i32* %18, i32** %2
%19 = load i32, i32* %16
switch i32 %19, label %27 [
i32 91, label %20
i32 93, label %24
i32 34, label %22
]
20: ; preds = %15
%21 = add nuw nsw i32 %17, 1
br label %27
22: ; preds = %15
%23 = call i32 @scan_text(i32** %2)
br label %27
24: ; preds = %15
%25 = add nsw i32 %17, -1
%26 = icmp eq i32 %25, 0
br i1 %26, label %47, label %27
27: ; preds = %20, %22, %15, %24
%28 = phi i32 [ %25, %24 ], [ %21, %20 ], [ %17, %22 ], [ %17, %15 ]
%29 = load i32*, i32** %2
br label %15
30: ; preds = %1, %42
%31 = phi i32* [ %44, %42 ], [ %5, %1 ]
%32 = phi i32 [ %43, %42 ], [ 1, %1 ]
%33 = getelementptr inbounds i32, i32* %31, i64 1
store i32* %33, i32** %2
%34 = load i32, i32* %31
switch i32 %34, label %42 [
i32 123, label %35
i32 125, label %39
i32 34, label %37
]
35: ; preds = %30
%36 = add nuw nsw i32 %32, 1
br label %42
37: ; preds = %30
%38 = call i32 @scan_text(i32** %2)
br label %42
39: ; preds = %30
%40 = add nsw i32 %32, -1
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %35, %37, %30, %39
%43 = phi i32 [ %40, %39 ], [ %36, %35 ], [ %32, %37 ], [ %32, %30 ]
%44 = load i32*, i32** %2
br label %30
45: ; preds = %1
store i32* %4, i32** %2
%46 = call i32 @scan_numeric(i32** %2)
br label %47
47: ; preds = %39, %24, %45, %13, %11, %9, %7
%48 = load i32*, i32** %2
store i32* %48, i32** %0
ret void
}