#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*/ ugl_AddBytecode(long);
int /*<<< orphan*/ ugl_plog(char *, long);
void ugl_bytecode_constant_value(long num) {
  ugl_plog("BC constant value %ld", num);
  if (num == 0) {
    ugl_AddBytecode((0x0f));
  } else if (num == 1) {
    ugl_AddBytecode((0x1f));
  } else if (num <= 0x0fff) {
    ugl_AddBytecode((0x00) | ((num & 0x0f00) >> 4));
    ugl_AddBytecode(num & 0xff);
  } else {
    ugl_AddBytecode((0x2f));
    ugl_AddBytecode(num >> 8);
    ugl_AddBytecode(num & 0x0ff);
  }
}


x86 assembly (clang, -O0):
<ugl_bytecode_constant_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1040 <ugl_plog@plt>
cmpq   $0x0,-0x8(%rbp)
jne    1156 <ugl_bytecode_constant_value+0x36>
mov    $0xf,%edi
call   1030 <ugl_AddBytecode@plt>
jmp    11dc <ugl_bytecode_constant_value+0xbc>
cmpq   $0x1,-0x8(%rbp)
jne    1170 <ugl_bytecode_constant_value+0x50>
mov    $0x1f,%edi
call   1030 <ugl_AddBytecode@plt>
jmp    11d7 <ugl_bytecode_constant_value+0xb7>
cmpq   $0xfff,-0x8(%rbp)
jg     11ab <ugl_bytecode_constant_value+0x8b>
mov    -0x8(%rbp),%rdi
and    $0xf00,%rdi
sar    $0x4,%rdi
or     $0x0,%rdi
call   1030 <ugl_AddBytecode@plt>
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
call   1030 <ugl_AddBytecode@plt>
jmp    11d2 <ugl_bytecode_constant_value+0xb2>
mov    $0x2f,%edi
call   1030 <ugl_AddBytecode@plt>
mov    -0x8(%rbp),%rdi
sar    $0x8,%rdi
call   1030 <ugl_AddBytecode@plt>
mov    -0x8(%rbp),%rdi
and    $0xff,%rdi
call   1030 <ugl_AddBytecode@plt>
jmp    11d7 <ugl_bytecode_constant_value+0xb7>
jmp    11dc <ugl_bytecode_constant_value+0xbc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ugl_bytecode_constant_value>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <ugl_plog@plt>
test   %rbx,%rbx
je     1149 <ugl_bytecode_constant_value+0x29>
cmp    $0x1,%rbx
jne    1154 <ugl_bytecode_constant_value+0x34>
mov    $0x1f,%edi
pop    %rbx
jmp    1030 <ugl_AddBytecode@plt>
mov    $0xf,%edi
pop    %rbx
jmp    1030 <ugl_AddBytecode@plt>
cmp    $0xfff,%rbx
jg     116c <ugl_bytecode_constant_value+0x4c>
mov    %rbx,%rdi
shr    $0x4,%rdi
and    $0xf0,%edi
jmp    117d <ugl_bytecode_constant_value+0x5d>
mov    $0x2f,%edi
call   1030 <ugl_AddBytecode@plt>
mov    %rbx,%rdi
shr    $0x8,%rdi
call   1030 <ugl_AddBytecode@plt>
movzbl %bl,%edi
pop    %rbx
jmp    1030 <ugl_AddBytecode@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"BC constant value %ld\00"
define void @ugl_bytecode_constant_value(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = call i32 @ugl_plog(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @ugl_AddBytecode(i64 15)
br label %36
9: ; preds = %1
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @ugl_AddBytecode(i64 31)
br label %35
14: ; preds = %9
%15 = load i64, i64* %2
%16 = icmp sle i64 %15, 4095
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i64, i64* %2
%19 = and i64 %18, 3840
%20 = ashr i64 %19, 4
%21 = or i64 0, %20
%22 = call i32 @ugl_AddBytecode(i64 %21)
%23 = load i64, i64* %2
%24 = and i64 %23, 255
%25 = call i32 @ugl_AddBytecode(i64 %24)
br label %34
26: ; preds = %14
%27 = call i32 @ugl_AddBytecode(i64 47)
%28 = load i64, i64* %2
%29 = ashr i64 %28, 8
%30 = call i32 @ugl_AddBytecode(i64 %29)
%31 = load i64, i64* %2
%32 = and i64 %31, 255
%33 = call i32 @ugl_AddBytecode(i64 %32)
br label %34
34: ; preds = %26, %17
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35, %7
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"BC constant value %ld\00"
define void @ugl_bytecode_constant_value(i64 %0) {
%2 = tail call i32 @ugl_plog(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %0)
switch i64 %0, label %4 [
i64 0, label %16
i64 1, label %3
]
3: ; preds = %1
br label %16
4: ; preds = %1
%5 = icmp slt i64 %0, 4096
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = lshr i64 %0, 4
%8 = and i64 %7, 240
%9 = tail call i32 @ugl_AddBytecode(i64 %8)
%10 = and i64 %0, 255
br label %16
11: ; preds = %4
%12 = tail call i32 @ugl_AddBytecode(i64 47)
%13 = lshr i64 %0, 8
%14 = tail call i32 @ugl_AddBytecode(i64 %13)
%15 = and i64 %0, 255
br label %16
16: ; preds = %1, %3, %11, %6
%17 = phi i64 [ 31, %3 ], [ %15, %11 ], [ %10, %6 ], [ 15, %1 ]
%18 = tail call i32 @ugl_AddBytecode(i64 %17)
ret void
}