#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*/ fprintf(int /*<<< orphan*/, char *, unsigned char,
                           unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void print_up(unsigned char *bottom, unsigned char *top) {
  int i;
  unsigned char *val;
  printf("%lx bottom -> %lx top: %ld bytes\n", bottom, top, top - bottom);
  for (i = 0, val = top; i < top - bottom; i++, val--) {
    fprintf(stderr, "%02x-%lx-%i\n", *val, val, i);
    printf("%02x", *val);
    if (i % 32 == 31)
      printf("\n");
    else if (i % 8 == 7)
      printf("  ");
    else if (i % 4 == 3)
      printf(" ");
  }
}


x86 assembly (clang, -O0):
<print_up>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jge    124c <print_up+0x12c>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe8c(%rip),%rsi
movzbl %al,%edx
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x1f,%edx
jne    11da <print_up+0xba>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122d <print_up+0x10d>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    1201 <print_up+0xe1>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <print_up+0x108>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1223 <print_up+0x103>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <print_up+0x108>
jmp    122d <print_up+0x10d>
jmp    1232 <print_up+0x112>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1160 <print_up+0x40>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_up>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%r14
sub    %rdi,%r14
lea    0xeb2(%rip),%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
jle    11f7 <print_up+0xc7>
mov    0x2e75(%rip),%r13
lea    0xeb0(%rip),%r15
lea    0xeb6(%rip),%r12
xor    %ebp,%ebp
jmp    119b <print_up+0x6b>
nopl   (%rax)
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
cmp    %rbp,%r14
je     11f7 <print_up+0xc7>
mov    0x0(%r13),%edi
movzbl (%rbx),%edx
mov    %r15,%rsi
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1050 <fprintf@plt>
movzbl (%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x1f,%al
jne    11e0 <print_up+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    118e <print_up+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
not    %eax
test   $0x7,%al
je     1180 <print_up+0x50>
mov    %ebp,%eax
not    %eax
test   $0x3,%al
jne    118e <print_up+0x5e>
mov    $0x20,%edi
jmp    11ca <print_up+0x9a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"%lx bottom -> %lx top: %ld bytes\0A\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"%02x-%lx-%i\0A\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c" \00"
@.str.5 = [2 x i8] c" \00"
define void @print_up(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = load i8*, i8** %4
%10 = load i8*, i8** %3
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8, i64 %13)
store i32 0, i32* %5
%15 = load i8*, i8** %4
store i8* %15, i8** %6
br label %16
16: ; preds = %56, %2
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = load i8*, i8** %4
%20 = load i8*, i8** %3
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = icmp slt i64 %18, %23
br i1 %24, label %25, label %61
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = load i8*, i8** %6
%30 = load i32, i32* %5
%31 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %28, i8* %29, i32 %30)
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %5
%37 = srem i32 %36, 32
%38 = icmp eq i32 %37, 31
br i1 %38, label %39, label %41
39: ; preds = %25
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %55
41: ; preds = %25
%42 = load i32, i32* %5
%43 = srem i32 %42, 8
%44 = icmp eq i32 %43, 7
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %54
47: ; preds = %41
%48 = load i32, i32* %5
%49 = srem i32 %48, 4
%50 = icmp eq i32 %49, 3
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53, %45
br label %55
55: ; preds = %54, %39
br label %56
56: ; preds = %55
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i32 -1
store i8* %60, i8** %6
br label %16
61: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"%lx bottom -> %lx top: %ld bytes\0A\00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"%02x-%lx-%i\0A\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.4 = [3 x i8] c" \00"
define void @print_up(i8* %0, i8* %1) {
%3 = ptrtoint i8* %1 to i64
%4 = ptrtoint i8* %0 to i64
%5 = sub i64 %3, %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i64 %5)
%7 = icmp sgt i64 %5, 0
br i1 %7, label %8, label %36
8: ; preds = %2, %32
%9 = phi i64 [ %33, %32 ], [ 0, %2 ]
%10 = phi i8* [ %34, %32 ], [ %1, %2 ]
%11 = load i32, i32* @stderr
%12 = load i8, i8* %10
%13 = trunc i64 %9 to i32
%14 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %12, i8* %10, i32 %13)
%15 = load i8, i8* %10
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = and i32 %13, 31
%19 = icmp eq i32 %18, 31
br i1 %19, label %20, label %22
20: ; preds = %8
%21 = tail call i32 @putchar(i32 10)
br label %32
22: ; preds = %8
%23 = and i32 %13, 7
%24 = icmp eq i32 %23, 7
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %32
27: ; preds = %22
%28 = and i32 %13, 3
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @putchar(i32 32)
br label %32
32: ; preds = %20, %27, %30, %25
%33 = add nuw nsw i64 %9, 1
%34 = getelementptr inbounds i8, i8* %10, i64 -1
%35 = icmp eq i64 %33, %5
br i1 %35, label %36, label %8
36: ; preds = %32, %2
ret void
}