#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 */
typedef scalar_t__ u_char;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void other_print(u_char *bp, int length) {
  u_char *ep;
  u_char *zp;
  ep = bp + length;
  for (zp = ep; zp > bp; zp--) {
    if (zp[-1] != 0)
      break;
  }
  if (zp == bp) {
    printf("-all-zero");
    return;
  }
  printf("-unknown");
  if (zp + 2 > ep)
    zp = ep;
  while (bp < zp) {
    printf(".%02X", *bp);
    bp++;
  }
  if (zp < ep)
    printf(".00...");
  return;
}


x86 assembly (clang, -O0):
<other_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1172 <other_print+0x62>
mov    -0x20(%rbp),%rax
cmpq   $0x0,-0x8(%rax)
je     115c <other_print+0x4c>
jmp    1172 <other_print+0x62>
jmp    1161 <other_print+0x51>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
jmp    113a <other_print+0x2a>
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1193 <other_print+0x83>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1215 <other_print+0x105>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
cmp    -0x18(%rbp),%rax
jbe    11bb <other_print+0xab>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11c0 <other_print+0xb0>
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11f4 <other_print+0xe4>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <other_print+0xb0>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1210 <other_print+0x100>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1215 <other_print+0x105>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<other_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
movslq %esi,%rax
lea    (%rdi,%rax,8),%r15
shl    $0x3,%rax
neg    %rax
mov    %r15,%rdx
nopl   0x0(%rax)
mov    %rdx,%rbx
mov    %rax,%rcx
cmp    %r12,%rdx
jbe    114a <other_print+0x3a>
lea    -0x8(%rbx),%rdx
lea    0x8(%rcx),%rax
cmpq   $0x0,-0x8(%rbx)
je     1130 <other_print+0x20>
test   %rcx,%rcx
je     11a5 <other_print+0x95>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rbx),%rax
cmp    %r15,%rax
cmova  %r15,%rbx
cmp    %r12,%rbx
jbe    1197 <other_print+0x87>
lea    0xe9f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%r12
cmp    %rbx,%r12
jb     1180 <other_print+0x70>
cmp    %r15,%rbx
jae    11be <other_print+0xae>
lea    0xe76(%rip),%rdi
jmp    11ac <other_print+0x9c>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"-all-zero\00"
@.str.1 = [9 x i8] c"-unknown\00"
@.str.2 = [6 x i8] c".%02X\00"
@.str.3 = [7 x i8] c".00...\00"
define void @other_print(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
store i64* %0, i64** %3
store i32 %1, i32* %4
%7 = load i64*, i64** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i64, i64* %7, i64 %9
store i64* %10, i64** %5
%11 = load i64*, i64** %5
store i64* %11, i64** %6
br label %12
12: ; preds = %23, %2
%13 = load i64*, i64** %6
%14 = load i64*, i64** %3
%15 = icmp ugt i64* %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i64*, i64** %6
%18 = getelementptr inbounds i64, i64* %17, i64 -1
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i64*, i64** %6
%25 = getelementptr inbounds i64, i64* %24, i32 -1
store i64* %25, i64** %6
br label %12
26: ; preds = %21, %12
%27 = load i64*, i64** %6
%28 = load i64*, i64** %3
%29 = icmp eq i64* %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %58
32: ; preds = %26
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%34 = load i64*, i64** %6
%35 = getelementptr inbounds i64, i64* %34, i64 2
%36 = load i64*, i64** %5
%37 = icmp ugt i64* %35, %36
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = load i64*, i64** %5
store i64* %39, i64** %6
br label %40
40: ; preds = %38, %32
br label %41
41: ; preds = %45, %40
%42 = load i64*, i64** %3
%43 = load i64*, i64** %6
%44 = icmp ult i64* %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i64*, i64** %3
%47 = load i64, i64* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %47)
%49 = load i64*, i64** %3
%50 = getelementptr inbounds i64, i64* %49, i32 1
store i64* %50, i64** %3
br label %41
51: ; preds = %41
%52 = load i64*, i64** %6
%53 = load i64*, i64** %5
%54 = icmp ult i64* %52, %53
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
br label %58
58: ; preds = %57, %30
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"-all-zero\00"
@.str.1 = [9 x i8] c"-unknown\00"
@.str.2 = [6 x i8] c".%02X\00"
@.str.3 = [7 x i8] c".00...\00"
define void @other_print(i64* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i64, i64* %0, i64 %3
br label %5
5: ; preds = %8, %2
%6 = phi i64* [ %4, %2 ], [ %9, %8 ]
%7 = icmp ugt i64* %6, %0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = getelementptr inbounds i64, i64* %6, i64 -1
%10 = load i64, i64* %9
%11 = icmp eq i64 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %8, %5
%13 = icmp eq i64* %6, %0
br i1 %13, label %28, label %14
14: ; preds = %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds i64, i64* %6, i64 2
%17 = icmp ugt i64* %16, %4
%18 = select i1 %17, i64* %4, i64* %6
%19 = icmp ugt i64* %18, %0
br i1 %19, label %20, label %26
20: ; preds = %14, %20
%21 = phi i64* [ %24, %20 ], [ %0, %14 ]
%22 = load i64, i64* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %22)
%24 = getelementptr inbounds i64, i64* %21, i64 1
%25 = icmp ult i64* %24, %18
br i1 %25, label %20, label %26
26: ; preds = %20, %14
%27 = icmp ult i64* %18, %4
br i1 %27, label %28, label %31
28: ; preds = %26, %12
%29 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %12 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %26 ]
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %29)
br label %31
31: ; preds = %28, %26
ret void
}