#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 */
int jsonsl__digit2int(char const);
int jsonsl__get_uescape_16(const char *s) {
  int ret = 0;
  int cur;
  cur = jsonsl__digit2int(s[0]);
  if (cur == -1) {
    return -1;
  }
  ret |= (cur << (12 - (0 * 4)));
  ;
  cur = jsonsl__digit2int(s[1]);
  if (cur == -1) {
    return -1;
  }
  ret |= (cur << (12 - (1 * 4)));
  ;
  cur = jsonsl__digit2int(s[2]);
  if (cur == -1) {
    return -1;
  }
  ret |= (cur << (12 - (2 * 4)));
  ;
  cur = jsonsl__digit2int(s[3]);
  if (cur == -1) {
    return -1;
  }
  ret |= (cur << (12 - (3 * 4)));
  ;
  return ret;
}


x86 assembly (clang, -O0):
<jsonsl__get_uescape_16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <jsonsl__digit2int@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1148 <jsonsl__get_uescape_16+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <jsonsl__get_uescape_16+0xe0>
mov    -0x18(%rbp),%eax
shl    $0xc,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <jsonsl__digit2int@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    117a <jsonsl__get_uescape_16+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <jsonsl__get_uescape_16+0xe0>
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <jsonsl__digit2int@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11ac <jsonsl__get_uescape_16+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <jsonsl__get_uescape_16+0xe0>
mov    -0x18(%rbp),%eax
shl    $0x4,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <jsonsl__digit2int@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11de <jsonsl__get_uescape_16+0xce>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f0 <jsonsl__get_uescape_16+0xe0>
mov    -0x18(%rbp),%eax
shl    $0x0,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonsl__get_uescape_16>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <jsonsl__digit2int@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     1177 <jsonsl__get_uescape_16+0x67>
mov    %eax,%ebp
movsbl 0x1(%rbx),%edi
call   1030 <jsonsl__digit2int@plt>
cmp    $0xffffffff,%eax
je     1177 <jsonsl__get_uescape_16+0x67>
mov    %eax,%r15d
movsbl 0x2(%rbx),%edi
call   1030 <jsonsl__digit2int@plt>
cmp    $0xffffffff,%eax
je     1177 <jsonsl__get_uescape_16+0x67>
mov    %eax,%r12d
movsbl 0x3(%rbx),%edi
call   1030 <jsonsl__digit2int@plt>
cmp    $0xffffffff,%eax
je     1177 <jsonsl__get_uescape_16+0x67>
shl    $0xc,%ebp
shl    $0x8,%r15d
or     %ebp,%r15d
shl    $0x4,%r12d
or     %r15d,%r12d
or     %eax,%r12d
mov    %r12d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jsonsl__get_uescape_16(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = call i32 @jsonsl__digit2int(i8 signext %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %55
13: ; preds = %1
%14 = load i32, i32* %5
%15 = shl i32 %14, 12
%16 = load i32, i32* %4
%17 = or i32 %16, %15
store i32 %17, i32* %4
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = call i32 @jsonsl__digit2int(i8 signext %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %13
store i32 -1, i32* %2
br label %55
25: ; preds = %13
%26 = load i32, i32* %5
%27 = shl i32 %26, 8
%28 = load i32, i32* %4
%29 = or i32 %28, %27
store i32 %29, i32* %4
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = call i32 @jsonsl__digit2int(i8 signext %32)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %37
36: ; preds = %25
store i32 -1, i32* %2
br label %55
37: ; preds = %25
%38 = load i32, i32* %5
%39 = shl i32 %38, 4
%40 = load i32, i32* %4
%41 = or i32 %40, %39
store i32 %41, i32* %4
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 3
%44 = load i8, i8* %43
%45 = call i32 @jsonsl__digit2int(i8 signext %44)
store i32 %45, i32* %5
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %49
48: ; preds = %37
store i32 -1, i32* %2
br label %55
49: ; preds = %37
%50 = load i32, i32* %5
%51 = shl i32 %50, 0
%52 = load i32, i32* %4
%53 = or i32 %52, %51
store i32 %53, i32* %4
%54 = load i32, i32* %4
store i32 %54, i32* %2
br label %55
55: ; preds = %49, %48, %36, %24, %12
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
define i32 @jsonsl__get_uescape_16(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @jsonsl__digit2int(i8 signext %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %27, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @jsonsl__digit2int(i8 signext %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %27, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = tail call i32 @jsonsl__digit2int(i8 signext %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %27, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %0, i64 3
%17 = load i8, i8* %16
%18 = tail call i32 @jsonsl__digit2int(i8 signext %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %27, label %20
20: ; preds = %15
%21 = shl i32 %3, 12
%22 = shl i32 %8, 8
%23 = or i32 %22, %21
%24 = shl i32 %13, 4
%25 = or i32 %23, %24
%26 = or i32 %25, %18
br label %27
27: ; preds = %15, %10, %5, %1, %20
%28 = phi i32 [ %26, %20 ], [ -1, %1 ], [ -1, %5 ], [ -1, %10 ], [ -1, %15 ]
ret i32 %28
}