#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 char u_int8_t;
typedef int u_int32_t;

/* Variables and functions */
int json_guess_type(u_int8_t ch, u_int32_t *type) {
  if (ch == '-' || (ch >= '0' && ch <= '9')) {
    *type = 0x0008;
    return (1);
  }
  switch (ch) {
  case '{':
    *type = 0x0001;
    break;
  case '"':
    *type = 0x0004;
    break;
  case '[':
    *type = 0x0002;
    break;
  case 'f':
  case 'n':
  case 't':
    *type = 0x0010;
    break;
  default:
    return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<json_guess_type>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
je     1135 <json_guess_type+0x35>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     114b <json_guess_type+0x4b>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     114b <json_guess_type+0x4b>
mov    -0x10(%rbp),%rax
movl   $0x8,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1204 <json_guess_type+0x104>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x22,%eax
je     11c4 <json_guess_type+0xc4>
jmp    1160 <json_guess_type+0x60>
mov    -0x14(%rbp),%eax
sub    $0x5b,%eax
je     11d3 <json_guess_type+0xd3>
jmp    1171 <json_guess_type+0x71>
mov    -0x14(%rbp),%eax
sub    $0x66,%eax
je     11e2 <json_guess_type+0xe2>
jmp    1182 <json_guess_type+0x82>
mov    -0x14(%rbp),%eax
sub    $0x6e,%eax
je     11e2 <json_guess_type+0xe2>
jmp    1193 <json_guess_type+0x93>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
je     11e2 <json_guess_type+0xe2>
jmp    11a4 <json_guess_type+0xa4>
mov    -0x14(%rbp),%eax
sub    $0x7b,%eax
jne    11f1 <json_guess_type+0xf1>
jmp    11b5 <json_guess_type+0xb5>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    11fd <json_guess_type+0xfd>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
jmp    11fd <json_guess_type+0xfd>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    11fd <json_guess_type+0xfd>
mov    -0x10(%rbp),%rax
movl   $0x10,(%rax)
jmp    11fd <json_guess_type+0xfd>
movl   $0x0,-0x4(%rbp)
jmp    1204 <json_guess_type+0x104>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_guess_type>:
mov    $0x8,%ecx
cmp    $0x2d,%dil
je     114d <json_guess_type+0x4d>
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
jb     114d <json_guess_type+0x4d>
movsbl %dil,%ecx
xor    %eax,%eax
lea    -0x5b(%rcx),%edx
cmp    $0x20,%edx
ja     113c <json_guess_type+0x3c>
mov    $0x1,%ecx
lea    0xed4(%rip),%rdi
movslq (%rdi,%rdx,4),%rdx
add    %rdi,%rdx
jmp    *%rdx
mov    $0x10,%ecx
jmp    114d <json_guess_type+0x4d>
cmp    $0x22,%ecx
jne    1154 <json_guess_type+0x54>
mov    $0x4,%ecx
jmp    114d <json_guess_type+0x4d>
mov    $0x2,%ecx
mov    %ecx,(%rsi)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @json_guess_type(i8 signext %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32*
store i8 %0, i8* %4
store i32* %1, i32** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 45
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp sge i32 %11, 48
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp sle i32 %15, 57
br i1 %16, label %17, label %19
17: ; preds = %13, %2
%18 = load i32*, i32** %5
store i32 8, i32* %18
store i32 1, i32* %3
br label %32
19: ; preds = %13, %9
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
switch i32 %21, label %30 [
i32 123, label %22
i32 34, label %24
i32 91, label %26
i32 102, label %28
i32 110, label %28
i32 116, label %28
]
22: ; preds = %19
%23 = load i32*, i32** %5
store i32 1, i32* %23
br label %31
24: ; preds = %19
%25 = load i32*, i32** %5
store i32 4, i32* %25
br label %31
26: ; preds = %19
%27 = load i32*, i32** %5
store i32 2, i32* %27
br label %31
28: ; preds = %19, %19, %19
%29 = load i32*, i32** %5
store i32 16, i32* %29
br label %31
30: ; preds = %19
store i32 0, i32* %3
br label %32
31: ; preds = %28, %26, %24, %22
store i32 1, i32* %3
br label %32
32: ; preds = %31, %30, %17
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @json_guess_type(i8 signext %0, i32* nocapture writeonly %1) {
%3 = icmp eq i8 %0, 45
%4 = add i8 %0, -48
%5 = icmp ult i8 %4, 10
%6 = or i1 %3, %5
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = sext i8 %0 to i32
switch i32 %8, label %14 [
i32 123, label %12
i32 34, label %9
i32 91, label %10
i32 102, label %11
i32 110, label %11
i32 116, label %11
]
9: ; preds = %7
br label %12
10: ; preds = %7
br label %12
11: ; preds = %7, %7, %7
br label %12
12: ; preds = %7, %2, %11, %10, %9
%13 = phi i32 [ 4, %9 ], [ 2, %10 ], [ 16, %11 ], [ 8, %2 ], [ 1, %7 ]
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %7
%15 = phi i32 [ 0, %7 ], [ 1, %12 ]
ret i32 %15
}