#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 output_print_bytes(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
void output_code(unsigned long addr, unsigned char *data, int size,
                 char *text) {
  printf("  %04lx: ", addr & 0xffff);
  int out = output_print_bytes(data, size);
  printf("   %s\n", text);
  while (out < size) {
    printf("          ");
    data += out;
    out += output_print_bytes(data, size - out);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<output_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
and    $0xffff,%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <output_print_bytes@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c4 <output_code+0xa4>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    -0x24(%rbp),%esi
call   1040 <output_print_bytes@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1171 <output_code+0x51>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_code>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %edx,%r14d
mov    %rsi,%r12
movzwl %di,%esi
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1050 <output_print_bytes@plt>
mov    %eax,%ebp
lea    0xea4(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r14d,%ebp
jge    11b0 <output_code+0x80>
lea    0xe95(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebp,%rbx
add    %rbx,%r12
mov    %r14d,%esi
sub    %ebx,%esi
mov    %r12,%rdi
call   1050 <output_print_bytes@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r14d,%ebp
jl     1180 <output_code+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" %04lx: \00"
@.str.1 = [7 x i8] c" %s\0A\00"
@.str.2 = [11 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @output_code(i64 %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i64 %0, i64* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i64, i64* %5
%11 = and i64 %10, 65535
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = call i32 @output_print_bytes(i8* %13, i32 %14)
store i32 %15, i32* %9
%16 = load i8*, i8** %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %22, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %9
%25 = load i8*, i8** %6
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %9
%31 = sub nsw i32 %29, %30
%32 = call i32 @output_print_bytes(i8* %28, i32 %31)
%33 = load i32, i32* %9
%34 = add nsw i32 %33, %32
store i32 %34, i32* %9
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %18
36: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" %04lx: \00"
@.str.1 = [7 x i8] c" %s\0A\00"
@.str.2 = [11 x i8] c" \00"
define void @output_code(i64 %0, i8* %1, i32 %2, i8* %3) {
%5 = and i64 %0, 65535
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %5)
%7 = tail call i32 @output_print_bytes(i8* %1, i32 %2)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = icmp slt i32 %7, %2
br i1 %9, label %10, label %21
10: ; preds = %4, %10
%11 = phi i32 [ %18, %10 ], [ %7, %4 ]
%12 = phi i8* [ %15, %10 ], [ %1, %4 ]
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = sub nsw i32 %2, %11
%17 = tail call i32 @output_print_bytes(i8* %15, i32 %16)
%18 = add nsw i32 %17, %11
%19 = tail call i32 @putchar(i32 10)
%20 = icmp slt i32 %18, %2
br i1 %20, label %10, label %21
21: ; preds = %10, %4
ret void
}