#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 */
scalar_t__ is_label(int);
int /*<<< orphan*/ lookup_label(int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void emit_bytes(int *addr, unsigned char *stack, int *sp) {
  char lab[512];
  int i;
  int numBytes = *sp;
  if (is_label(*addr)) {
    lookup_label(*addr, lab, 512 - 1);
  } else {
    lab[0] = '\0';
  }
  printf("%-23s %-20s ", lab, "!byte");
  for (i = 0; i < numBytes; i++) {
    printf("$%02x", stack[i]);
    if ((i + 1) < numBytes) {
      putchar(',');
    }
  }
  for (i = numBytes; i < 16; i++) {
    printf("    ");
  }
  printf(" ; %04x\n", *addr);
  *addr = -1;
  *sp = 0;
}


x86 assembly (clang, -O0):
<emit_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x228(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <is_label@plt>
cmp    $0x0,%rax
je     1194 <emit_bytes+0x54>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rsi
mov    $0x1ff,%edx
call   1060 <lookup_label@plt>
jmp    119b <emit_bytes+0x5b>
movb   $0x0,-0x220(%rbp)
lea    -0x220(%rbp),%rsi
lea    0xe57(%rip),%rdi
lea    0xe5d(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x224(%rbp)
mov    -0x224(%rbp),%eax
cmp    -0x228(%rbp),%eax
jge    1228 <emit_bytes+0xe8>
mov    -0x10(%rbp),%rax
movslq -0x224(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
cmp    -0x228(%rbp),%eax
jge    120f <emit_bytes+0xcf>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    1214 <emit_bytes+0xd4>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    11c1 <emit_bytes+0x81>
mov    -0x228(%rbp),%eax
mov    %eax,-0x224(%rbp)
cmpl   $0x10,-0x224(%rbp)
jge    1263 <emit_bytes+0x123>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    1234 <emit_bytes+0xf4>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%r15
mov    (%rdx),%ebx
mov    (%rdi),%edi
call   1050 <is_label@plt>
test   %rax,%rax
je     117c <emit_bytes+0x3c>
mov    (%r15),%edi
lea    0x10(%rsp),%rsi
mov    $0x1ff,%edx
call   1060 <lookup_label@plt>
jmp    1181 <emit_bytes+0x41>
movb   $0x0,0x10(%rsp)
lea    0xe78(%rip),%rdi
lea    0xe7e(%rip),%rdx
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11fd <emit_bytes+0xbd>
mov    %rbp,0x8(%rsp)
mov    %rbx,%rbp
neg    %rbp
mov    $0x1,%r14d
lea    0xe5c(%rip),%r12
jmp    11d2 <emit_bytes+0x92>
nopl   0x0(%rax)
lea    (%r14,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%r14
cmp    $0x1,%rax
je     11f3 <emit_bytes+0xb3>
movzbl -0x1(%r13,%r14,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%r14
jae    11c0 <emit_bytes+0x80>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    11c0 <emit_bytes+0x80>
cmp    $0xf,%ebx
mov    0x8(%rsp),%rbp
jg     121e <emit_bytes+0xde>
add    $0xfffffff0,%ebx
lea    0xe12(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
inc    %ebx
jne    1210 <emit_bytes+0xd0>
mov    (%r15),%esi
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xffffffff,(%r15)
movl   $0x0,0x0(%rbp)
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%-23s %-20s \00"
@.str.1 = [6 x i8] c"!byte\00"
@.str.2 = [6 x i8] c"$%02x\00"
@.str.3 = [5 x i8] c" \00"
@.str.4 = [9 x i8] c" ; %04x\0A\00"
define void @emit_bytes(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [512 x i8]
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
store i32 %11, i32* %9
%12 = load i32*, i32** %4
%13 = load i32, i32* %12
%14 = call i64 @is_label(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%20 = call i32 @lookup_label(i32 %18, i8* %19, i32 511)
br label %23
21: ; preds = %3
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8 0, i8* %22
br label %23
23: ; preds = %21, %16
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %26
26: ; preds = %45, %23
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %48
30: ; preds = %26
%31 = load i8*, i8** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
%40 = load i32, i32* %9
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %30
%43 = call i32 @putchar(i8 signext 44)
br label %44
44: ; preds = %42, %30
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %26
48: ; preds = %26
%49 = load i32, i32* %9
store i32 %49, i32* %8
br label %50
50: ; preds = %55, %48
%51 = load i32, i32* %8
%52 = icmp slt i32 %51, 16
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %50
58: ; preds = %50
%59 = load i32*, i32** %4
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = load i32*, i32** %4
store i32 -1, i32* %62
%63 = load i32*, i32** %6
store i32 0, i32* %63
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%-23s %-20s \00"
@.str.1 = [6 x i8] c"!byte\00"
@.str.2 = [6 x i8] c"$%02x\00"
@.str.3 = [5 x i8] c" \00"
@.str.4 = [9 x i8] c" ; %04x\0A\00"
define void @emit_bytes(i32* nocapture %0, i8* nocapture %1, i32* nocapture %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* %2
%7 = load i32, i32* %0
%8 = tail call i64 @is_label(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %0
%12 = call i32 @lookup_label(i32 %11, i8* %5, i32 511)
br label %14
13: ; preds = %3
store i8 0, i8* %5
br label %14
14: ; preds = %13, %10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp sgt i32 %6, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = zext i32 %6 to i64
%19 = zext i32 %6 to i64
br label %23
20: ; preds = %33
%21 = icmp slt i32 %6, 16
br i1 %21, label %22, label %40
22: ; preds = %14, %20
br label %35
23: ; preds = %17, %33
%24 = phi i64 [ 0, %17 ], [ %29, %33 ]
%25 = getelementptr inbounds i8, i8* %1, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp ult i64 %29, %18
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @putchar(i8 signext 44)
br label %33
33: ; preds = %23, %31
%34 = icmp eq i64 %29, %19
br i1 %34, label %20, label %23
35: ; preds = %22, %35
%36 = phi i32 [ %38, %35 ], [ %6, %22 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = add i32 %36, 1
%39 = icmp eq i32 %38, 16
br i1 %39, label %40, label %35
40: ; preds = %35, %20
%41 = load i32, i32* %0
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %41)
store i32 -1, i32* %0
store i32 0, i32* %2
ret void
}