#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 */
unsigned long long uint2korr(char *);
unsigned long long uint3korr(char *);
unsigned long long uint8korr(char *);
int my_lcb_ll(char *m, unsigned long long *r, char *nul, int len) {
  if (len < 1)
    return -1;
  switch ((unsigned char)m[0]) {
  case 251:
    *r = 0;
    *nul = 1;
    return 1;
  case 252:
    if (len < 3)
      return -1;
    *r = uint2korr(&m[1]);
    *nul = 0;
    return 3;
  case 253:
    if (len < 4)
      return -1;
    *r = uint3korr(&m[1]);
    *nul = 0;
    return 4;
  case 254:
    if (len < 9)
      return -1;
    *r = uint8korr(&m[1]);
    *nul = 0;
    return 9;
  default:
    *r = (unsigned char)m[0];
    *nul = 0;
    return 1;
  }
}


x86 assembly (clang, -O0):
<my_lcb_ll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jge    115d <my_lcb_ll+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0xffffff05,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     126a <my_lcb_ll+0x13a>
mov    -0x30(%rbp),%rax
lea    0xe7d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
cmpl   $0x3,-0x24(%rbp)
jge    11c0 <my_lcb_ll+0x90>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <uint2korr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
cmpl   $0x4,-0x24(%rbp)
jge    1200 <my_lcb_ll+0xd0>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <uint3korr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x4,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
cmpl   $0x9,-0x24(%rbp)
jge    1240 <my_lcb_ll+0x110>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <uint8korr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x9,-0x4(%rbp)
jmp    1288 <my_lcb_ll+0x158>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_lcb_ll>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    $0xffffffff,%edx
test   %ecx,%ecx
jle    11bb <my_lcb_ll+0x8b>
mov    %rsi,%r15
movzbl (%rdi),%eax
mov    $0x1,%r8d
lea    0x5(%rax),%esi
cmp    $0x3,%sil
ja     11af <my_lcb_ll+0x7f>
mov    $0x1,%r9b
xor    %eax,%eax
movzbl %sil,%esi
lea    0xe9a(%rip),%rbx
movslq (%rbx,%rsi,4),%rsi
add    %rbx,%rsi
jmp    *%rsi
cmp    $0x3,%ecx
jb     11bb <my_lcb_ll+0x8b>
add    $0x1,%rdi
call   1030 <uint2korr@plt>
mov    $0x3,%r8d
jmp    11af <my_lcb_ll+0x7f>
cmp    $0x4,%ecx
jb     11bb <my_lcb_ll+0x8b>
add    $0x1,%rdi
call   1050 <uint3korr@plt>
mov    $0x4,%r8d
jmp    11af <my_lcb_ll+0x7f>
cmp    $0x9,%ecx
jb     11bb <my_lcb_ll+0x8b>
add    $0x1,%rdi
call   1040 <uint8korr@plt>
mov    $0x9,%r8d
xor    %r9d,%r9d
mov    %rax,(%r15)
mov    %r9b,(%r14)
mov    %r8d,%edx
mov    %edx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @my_lcb_ll(i8* %0, i64* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %6
store i64* %1, i64** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 -1, i32* %5
br label %58
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
switch i32 %17, label %51 [
i32 251, label %18
i32 252, label %21
i32 253, label %31
i32 254, label %41
]
18: ; preds = %13
%19 = load i64*, i64** %7
store i64 0, i64* %19
%20 = load i8*, i8** %8
store i8 1, i8* %20
store i32 1, i32* %5
br label %58
21: ; preds = %13
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 -1, i32* %5
br label %58
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i64 @uint2korr(i8* %27)
%29 = load i64*, i64** %7
store i64 %28, i64* %29
%30 = load i8*, i8** %8
store i8 0, i8* %30
store i32 3, i32* %5
br label %58
31: ; preds = %13
%32 = load i32, i32* %9
%33 = icmp slt i32 %32, 4
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 -1, i32* %5
br label %58
35: ; preds = %31
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i64 @uint3korr(i8* %37)
%39 = load i64*, i64** %7
store i64 %38, i64* %39
%40 = load i8*, i8** %8
store i8 0, i8* %40
store i32 4, i32* %5
br label %58
41: ; preds = %13
%42 = load i32, i32* %9
%43 = icmp slt i32 %42, 9
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 -1, i32* %5
br label %58
45: ; preds = %41
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = call i64 @uint8korr(i8* %47)
%49 = load i64*, i64** %7
store i64 %48, i64* %49
%50 = load i8*, i8** %8
store i8 0, i8* %50
store i32 9, i32* %5
br label %58
51: ; preds = %13
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i64 0
%54 = load i8, i8* %53
%55 = zext i8 %54 to i64
%56 = load i64*, i64** %7
store i64 %55, i64* %56
%57 = load i8*, i8** %8
store i8 0, i8* %57
store i32 1, i32* %5
br label %58
58: ; preds = %51, %45, %44, %35, %34, %25, %24, %18, %12
%59 = load i32, i32* %5
ret i32 %59
}

LLVM IR (-O2):
define i32 @my_lcb_ll(i8* %0, i64* nocapture writeonly %1, i8* nocapture writeonly %2, i32 %3) {
%5 = icmp slt i32 %3, 1
br i1 %5, label %29, label %6
6: ; preds = %4
%7 = load i8, i8* %0
switch i8 %7, label %23 [
i8 -5, label %25
i8 -4, label %8
i8 -3, label %13
i8 -2, label %18
]
8: ; preds = %6
%9 = icmp ult i32 %3, 3
br i1 %9, label %29, label %10
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = tail call i64 @uint2korr(i8* %11)
br label %25
13: ; preds = %6
%14 = icmp ult i32 %3, 4
br i1 %14, label %29, label %15
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %0, i64 1
%17 = tail call i64 @uint3korr(i8* %16)
br label %25
18: ; preds = %6
%19 = icmp ult i32 %3, 9
br i1 %19, label %29, label %20
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %0, i64 1
%22 = tail call i64 @uint8korr(i8* %21)
br label %25
23: ; preds = %6
%24 = zext i8 %7 to i64
br label %25
25: ; preds = %6, %10, %15, %20, %23
%26 = phi i64 [ %24, %23 ], [ %22, %20 ], [ %17, %15 ], [ %12, %10 ], [ 0, %6 ]
%27 = phi i8 [ 0, %23 ], [ 0, %20 ], [ 0, %15 ], [ 0, %10 ], [ 1, %6 ]
%28 = phi i32 [ 1, %23 ], [ 9, %20 ], [ 4, %15 ], [ 3, %10 ], [ 1, %6 ]
store i64 %26, i64* %1
store i8 %27, i8* %2
br label %29
29: ; preds = %25, %18, %13, %8, %4
%30 = phi i32 [ -1, %4 ], [ -1, %8 ], [ -1, %13 ], [ -1, %18 ], [ %28, %25 ]
ret i32 %30
}