#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 */
char const *pbjson_find_end_complex(char const *, char const *);
char const *pbjson_find_end_primitive(char const *, char const *);
char const *pbjson_find_end_string(char const *, char const *);
char const *pbjson_find_end_element(char const *start, char const *end) {
  switch (*start) {
  case '"':
    return pbjson_find_end_string(start + 1, end);
  case '{':
  case '[':
    return pbjson_find_end_complex(start, end);
  default:
    return pbjson_find_end_primitive(start + 1, end);
  }
}


x86 assembly (clang, -O0):
<pbjson_find_end_element>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x22,%eax
je     117a <pbjson_find_end_element+0x4a>
jmp    1158 <pbjson_find_end_element+0x28>
mov    -0x1c(%rbp),%eax
sub    $0x5b,%eax
je     1194 <pbjson_find_end_element+0x64>
jmp    1169 <pbjson_find_end_element+0x39>
mov    -0x1c(%rbp),%eax
sub    $0x7b,%eax
je     1194 <pbjson_find_end_element+0x64>
jmp    11aa <pbjson_find_end_element+0x7a>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <pbjson_find_end_string@plt>
mov    %rax,-0x8(%rbp)
jmp    11bf <pbjson_find_end_element+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <pbjson_find_end_complex@plt>
mov    %rax,-0x8(%rbp)
jmp    11bf <pbjson_find_end_element+0x8f>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <pbjson_find_end_primitive@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbjson_find_end_element>:
movsbl (%rdi),%eax
cmp    $0x7b,%eax
je     114b <pbjson_find_end_element+0x1b>
cmp    $0x5b,%eax
je     114b <pbjson_find_end_element+0x1b>
add    $0x1,%rdi
cmp    $0x22,%eax
jne    1150 <pbjson_find_end_element+0x20>
jmp    1040 <pbjson_find_end_string@plt>
jmp    1050 <pbjson_find_end_complex@plt>
jmp    1030 <pbjson_find_end_primitive@plt>

LLVM IR (-O0):
define i8* @pbjson_find_end_element(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %18 [
i32 34, label %9
i32 123, label %14
i32 91, label %14
]
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8*, i8** %5
%13 = call i8* @pbjson_find_end_string(i8* %11, i8* %12)
store i8* %13, i8** %3
br label %23
14: ; preds = %2, %2
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i8* @pbjson_find_end_complex(i8* %15, i8* %16)
store i8* %17, i8** %3
br label %23
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8*, i8** %5
%22 = call i8* @pbjson_find_end_primitive(i8* %20, i8* %21)
store i8* %22, i8** %3
br label %23
23: ; preds = %18, %14, %9
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
define i8* @pbjson_find_end_element(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
switch i32 %4, label %10 [
i32 34, label %5
i32 123, label %8
i32 91, label %8
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i8* @pbjson_find_end_string(i8* %6, i8* %1)
br label %13
8: ; preds = %2, %2
%9 = tail call i8* @pbjson_find_end_complex(i8* %0, i8* %1)
br label %13
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = tail call i8* @pbjson_find_end_primitive(i8* %11, i8* %1)
br label %13
13: ; preds = %10, %8, %5
%14 = phi i8* [ %12, %10 ], [ %9, %8 ], [ %7, %5 ]
ret i8* %14
}