#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 /*<<< orphan*/ to_my_2(unsigned long long, char *);
int /*<<< orphan*/ to_my_3(unsigned long long, char *);
int /*<<< orphan*/ to_my_4(unsigned long long, char *);
int set_my_lcb(unsigned long long len, int null, char *out, int out_len) {
  if (null == 1) {
    if (out_len < 1)
      return -1;
    out[0] = 251;
    return 1;
  }
  if (len <= 250) {
    if (out_len < 1)
      return -1;
    out[0] = len;
    return 1;
  }
  if (len >= 251 && len < 0xffff) {
    if (out_len < 3)
      return -1;
    out[0] = 252;
    to_my_2(len, &out[1]);
    return 3;
  }
  if (len > 0xffff && len <= 0xffffff) {
    if (out_len < 4)
      return -1;
    out[0] = 253;
    to_my_3(len, &out[1]);
    return 4;
  }
  if (len > 0xffffff && len <= 0xffffffff) {
    if (out_len < 5)
      return -1;
    out[0] = 254;
    to_my_4(len, &out[1]);
    return 5;
  }
  if (len > 0xffffffff && len <= 0xffffffffffffffffULL) {
    if (out_len < 9)
      return -1;
    out[0] = 254;
    to_my_4(len, &out[1]);
    return 9;
  }
  return -1;
}


x86 assembly (clang, -O0):
<set_my_lcb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1179 <set_my_lcb+0x49>
cmpl   $0x1,-0x24(%rbp)
jge    1166 <set_my_lcb+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x20(%rbp),%rax
movb   $0xfb,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
cmpq   $0xfa,-0x10(%rbp)
ja     11b5 <set_my_lcb+0x85>
cmpl   $0x1,-0x24(%rbp)
jge    119d <set_my_lcb+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x10(%rbp),%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
cmpq   $0xfb,-0x10(%rbp)
jb     120b <set_my_lcb+0xdb>
cmpq   $0xffff,-0x10(%rbp)
jae    120b <set_my_lcb+0xdb>
cmpl   $0x3,-0x24(%rbp)
jge    11e7 <set_my_lcb+0xb7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x20(%rbp),%rax
movb   $0xfc,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1050 <to_my_2@plt>
movl   $0x3,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
cmpq   $0xffff,-0x10(%rbp)
jbe    1261 <set_my_lcb+0x131>
cmpq   $0xffffff,-0x10(%rbp)
ja     1261 <set_my_lcb+0x131>
cmpl   $0x4,-0x24(%rbp)
jge    123d <set_my_lcb+0x10d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x20(%rbp),%rax
movb   $0xfd,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <to_my_3@plt>
movl   $0x4,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
cmpq   $0xffffff,-0x10(%rbp)
jbe    12b8 <set_my_lcb+0x188>
mov    $0xffffffff,%eax
cmp    %rax,-0x10(%rbp)
ja     12b8 <set_my_lcb+0x188>
cmpl   $0x5,-0x24(%rbp)
jge    1294 <set_my_lcb+0x164>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x20(%rbp),%rax
movb   $0xfe,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1040 <to_my_4@plt>
movl   $0x5,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    $0xffffffff,%eax
cmp    %rax,-0x10(%rbp)
jbe    130c <set_my_lcb+0x1dc>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
ja     130c <set_my_lcb+0x1dc>
cmpl   $0x9,-0x24(%rbp)
jge    12e8 <set_my_lcb+0x1b8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
mov    -0x20(%rbp),%rax
movb   $0xfe,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1040 <to_my_4@plt>
movl   $0x9,-0x4(%rbp)
jmp    1313 <set_my_lcb+0x1e3>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_my_lcb>:
push   %rax
cmp    $0x1,%esi
jne    113f <set_my_lcb+0xf>
test   %ecx,%ecx
jle    1156 <set_my_lcb+0x26>
movb   $0xfb,(%rdx)
jmp    114f <set_my_lcb+0x1f>
cmp    $0xfa,%rdi
ja     115d <set_my_lcb+0x2d>
test   %ecx,%ecx
jle    1156 <set_my_lcb+0x26>
mov    %dil,(%rdx)
mov    $0x1,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret
cmp    $0xfffe,%rdi
ja     118a <set_my_lcb+0x5a>
mov    $0xffffffff,%eax
cmp    $0x3,%ecx
jl     1216 <set_my_lcb+0xe6>
movb   $0xfc,(%rdx)
add    $0x1,%rdx
mov    %rdx,%rsi
call   1050 <to_my_2@plt>
mov    $0x3,%eax
pop    %rcx
ret
cmp    $0xffff,%rdi
je     11bc <set_my_lcb+0x8c>
cmp    $0xffffff,%rdi
ja     11bc <set_my_lcb+0x8c>
mov    $0xffffffff,%eax
cmp    $0x4,%ecx
jl     1216 <set_my_lcb+0xe6>
movb   $0xfd,(%rdx)
add    $0x1,%rdx
mov    %rdx,%rsi
call   1030 <to_my_3@plt>
mov    $0x4,%eax
pop    %rcx
ret
lea    -0x1000000(%rdi),%rax
shr    $0x18,%rax
cmp    $0xfe,%rax
ja     11ef <set_my_lcb+0xbf>
mov    $0xffffffff,%eax
cmp    $0x5,%ecx
jl     1216 <set_my_lcb+0xe6>
movb   $0xfe,(%rdx)
add    $0x1,%rdx
mov    %rdx,%rsi
call   1040 <to_my_4@plt>
mov    $0x5,%eax
pop    %rcx
ret
mov    %rdi,%rax
shr    $0x20,%rax
mov    $0xffffffff,%eax
je     1216 <set_my_lcb+0xe6>
cmp    $0x9,%ecx
jl     1216 <set_my_lcb+0xe6>
movb   $0xfe,(%rdx)
add    $0x1,%rdx
mov    %rdx,%rsi
call   1040 <to_my_4@plt>
mov    $0x9,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @set_my_lcb(i64 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i64 %0, i64* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 -1, i32* %5
br label %100
16: ; preds = %12
%17 = load i8*, i8** %8
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 -5, i8* %18
store i32 1, i32* %5
br label %100
19: ; preds = %4
%20 = load i64, i64* %6
%21 = icmp ule i64 %20, 250
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 -1, i32* %5
br label %100
26: ; preds = %22
%27 = load i64, i64* %6
%28 = trunc i64 %27 to i8
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 %28, i8* %30
store i32 1, i32* %5
br label %100
31: ; preds = %19
%32 = load i64, i64* %6
%33 = icmp uge i64 %32, 251
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = load i64, i64* %6
%36 = icmp ult i64 %35, 65535
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = load i32, i32* %9
%39 = icmp slt i32 %38, 3
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 -1, i32* %5
br label %100
41: ; preds = %37
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 0
store i8 -4, i8* %43
%44 = load i64, i64* %6
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = call i32 @to_my_2(i64 %44, i8* %46)
store i32 3, i32* %5
br label %100
48: ; preds = %34, %31
%49 = load i64, i64* %6
%50 = icmp ugt i64 %49, 65535
br i1 %50, label %51, label %65
51: ; preds = %48
%52 = load i64, i64* %6
%53 = icmp ule i64 %52, 16777215
br i1 %53, label %54, label %65
54: ; preds = %51
%55 = load i32, i32* %9
%56 = icmp slt i32 %55, 4
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 -1, i32* %5
br label %100
58: ; preds = %54
%59 = load i8*, i8** %8
%60 = getelementptr inbounds i8, i8* %59, i64 0
store i8 -3, i8* %60
%61 = load i64, i64* %6
%62 = load i8*, i8** %8
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = call i32 @to_my_3(i64 %61, i8* %63)
store i32 4, i32* %5
br label %100
65: ; preds = %51, %48
%66 = load i64, i64* %6
%67 = icmp ugt i64 %66, 16777215
br i1 %67, label %68, label %82
68: ; preds = %65
%69 = load i64, i64* %6
%70 = icmp ule i64 %69, 4294967295
br i1 %70, label %71, label %82
71: ; preds = %68
%72 = load i32, i32* %9
%73 = icmp slt i32 %72, 5
br i1 %73, label %74, label %75
74: ; preds = %71
store i32 -1, i32* %5
br label %100
75: ; preds = %71
%76 = load i8*, i8** %8
%77 = getelementptr inbounds i8, i8* %76, i64 0
store i8 -2, i8* %77
%78 = load i64, i64* %6
%79 = load i8*, i8** %8
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = call i32 @to_my_4(i64 %78, i8* %80)
store i32 5, i32* %5
br label %100
82: ; preds = %68, %65
%83 = load i64, i64* %6
%84 = icmp ugt i64 %83, 4294967295
br i1 %84, label %85, label %99
85: ; preds = %82
%86 = load i64, i64* %6
%87 = icmp ule i64 %86, -1
br i1 %87, label %88, label %99
88: ; preds = %85
%89 = load i32, i32* %9
%90 = icmp slt i32 %89, 9
br i1 %90, label %91, label %92
91: ; preds = %88
store i32 -1, i32* %5
br label %100
92: ; preds = %88
%93 = load i8*, i8** %8
%94 = getelementptr inbounds i8, i8* %93, i64 0
store i8 -2, i8* %94
%95 = load i64, i64* %6
%96 = load i8*, i8** %8
%97 = getelementptr inbounds i8, i8* %96, i64 1
%98 = call i32 @to_my_4(i64 %95, i8* %97)
store i32 9, i32* %5
br label %100
99: ; preds = %85, %82
store i32 -1, i32* %5
br label %100
100: ; preds = %99, %92, %91, %75, %74, %58, %57, %41, %40, %26, %25, %16, %15
%101 = load i32, i32* %5
ret i32 %101
}

LLVM IR (-O2):
define i32 @set_my_lcb(i64 %0, i32 %1, i8* %2, i32 %3) {
%5 = icmp eq i32 %1, 1
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = icmp slt i32 %3, 1
br i1 %7, label %46, label %8
8: ; preds = %6
store i8 -5, i8* %2
br label %46
9: ; preds = %4
%10 = icmp ult i64 %0, 251
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = icmp slt i32 %3, 1
br i1 %12, label %46, label %13
13: ; preds = %11
%14 = trunc i64 %0 to i8
store i8 %14, i8* %2
br label %46
15: ; preds = %9
%16 = icmp ult i64 %0, 65535
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = icmp slt i32 %3, 3
br i1 %18, label %46, label %19
19: ; preds = %17
store i8 -4, i8* %2
%20 = getelementptr inbounds i8, i8* %2, i64 1
%21 = tail call i32 @to_my_2(i64 %0, i8* %20)
br label %46
22: ; preds = %15
%23 = icmp ne i64 %0, 65535
%24 = icmp ult i64 %0, 16777216
%25 = and i1 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = icmp slt i32 %3, 4
br i1 %27, label %46, label %28
28: ; preds = %26
store i8 -3, i8* %2
%29 = getelementptr inbounds i8, i8* %2, i64 1
%30 = tail call i32 @to_my_3(i64 %0, i8* %29)
br label %46
31: ; preds = %22
%32 = add i64 %0, -16777216
%33 = icmp ult i64 %32, 4278190080
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = icmp slt i32 %3, 5
br i1 %35, label %46, label %36
36: ; preds = %34
store i8 -2, i8* %2
%37 = getelementptr inbounds i8, i8* %2, i64 1
%38 = tail call i32 @to_my_4(i64 %0, i8* %37)
br label %46
39: ; preds = %31
%40 = icmp ult i64 %0, 4294967296
%41 = icmp slt i32 %3, 9
%42 = or i1 %40, %41
br i1 %42, label %46, label %43
43: ; preds = %39
store i8 -2, i8* %2
%44 = getelementptr inbounds i8, i8* %2, i64 1
%45 = tail call i32 @to_my_4(i64 %0, i8* %44)
br label %46
46: ; preds = %39, %34, %26, %17, %11, %6, %43, %36, %28, %19, %13, %8
%47 = phi i32 [ 1, %8 ], [ 1, %13 ], [ 3, %19 ], [ 4, %28 ], [ 5, %36 ], [ 9, %43 ], [ -1, %6 ], [ -1, %11 ], [ -1, %17 ], [ -1, %26 ], [ -1, %34 ], [ -1, %39 ]
ret i32 %47
}