#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(int);
int /*<<< orphan*/ ugl_plog(char *, char *, char const *);
void ugl_bytecode_buildin_procedure(const char *name, int idx,
                                    int is_toplevel) {
  ugl_plog("BC %scall buildin '%s'", is_toplevel ? "toplevel " : "", name);
  if (is_toplevel == 0) {
    ugl_AddBytecode((0x01) | ((idx & 0x0f00) >> 4));
    ugl_AddBytecode(idx & 0xff);
  } else {
    ugl_AddBytecode((0x02) | ((idx & 0x0f00) >> 4));
    ugl_AddBytecode(idx & 0xff);
  }
}


x86 assembly (clang, -O0):
<ugl_bytecode_buildin_procedure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
lea    0xee4(%rip),%rsi
lea    0xed4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x8(%rbp),%rdx
lea    0xeab(%rip),%rdi
call   1040 <ugl_plog@plt>
cmpl   $0x0,-0x10(%rbp)
jne    118b <ugl_bytecode_buildin_procedure+0x6b>
mov    -0xc(%rbp),%edi
and    $0xf00,%edi
sar    $0x4,%edi
or     $0x1,%edi
call   1030 <ugl_AddBytecode@plt>
mov    -0xc(%rbp),%edi
and    $0xff,%edi
call   1030 <ugl_AddBytecode@plt>
jmp    11ad <ugl_bytecode_buildin_procedure+0x8d>
mov    -0xc(%rbp),%edi
and    $0xf00,%edi
sar    $0x4,%edi
or     $0x2,%edi
call   1030 <ugl_AddBytecode@plt>
mov    -0xc(%rbp),%edi
and    $0xff,%edi
call   1030 <ugl_AddBytecode@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ugl_bytecode_buildin_procedure>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rax
xor    %ebp,%ebp
test   %edx,%edx
sete   %bpl
lea    0xee9(%rip),%rcx
lea    0xed9(%rip),%rsi
cmove  %rcx,%rsi
lea    0xeb7(%rip),%rdi
mov    %rax,%rdx
call   1040 <ugl_plog@plt>
mov    %ebx,%edi
shr    $0x4,%edi
and    $0xf0,%edi
sub    %ebp,%edi
add    $0x2,%edi
call   1030 <ugl_AddBytecode@plt>
movzbl %bl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ugl_AddBytecode@plt>

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

LLVM IR (-O2):
@.str = [23 x i8] c"BC %scall buildin '%s'\00"
@.str.1 = [10 x i8] c"toplevel \00"
@.str.2 = [1 x i8] zeroinitializer
define void @ugl_bytecode_buildin_procedure(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
%6 = tail call i32 @ugl_plog(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %0)
%7 = lshr i32 %1, 4
%8 = and i32 %7, 240
%9 = select i1 %4, i32 1, i32 2
%10 = or i32 %8, %9
%11 = tail call i32 @ugl_AddBytecode(i32 %10)
%12 = and i32 %1, 255
%13 = tail call i32 @ugl_AddBytecode(i32 %12)
ret void
}