#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 int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_tbl(char *s, uint8_t *tbl, uint32_t len) {
  uint32_t i;
  uint8_t *p = tbl;
  p++;
  printf("\n%s:\n  db  0x%02x,", s, *p++);
  for (i = 0; i < len - 2; i++) {
    if ((i % 8) == 0)
      printf("\n  db  ");
    printf("0x%02x, ", *p++ - 1);
  }
}


x86 assembly (clang, -O0):
<print_tbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%edx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11c4 <print_tbl+0xb4>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1194 <print_tbl+0x84>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%esi
sub    $0x1,%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1161 <print_tbl+0x51>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tbl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%rsi
mov    0x4(%r12),%edx
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%ebp
jl     117b <print_tbl+0x6b>
add    $0xfffffffe,%ebp
mov    %ebp,%ebp
lea    0xecf(%rip),%r14
lea    0xed0(%rip),%r15
xor    %ebx,%ebx
jmp    116a <print_tbl+0x5a>
nop
mov    0x8(%r12,%rbx,4),%esi
add    $0xffffffff,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
je     117b <print_tbl+0x6b>
test   $0x7,%bl
jne    1150 <print_tbl+0x40>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <print_tbl+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"\0A%s:\0A db 0x%02x,\00"
@.str.1 = [8 x i8] c"\0A db \00"
@.str.2 = [9 x i8] c"0x%02x, \00"
define void @print_tbl(i8* %0, i32* nocapture %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %1, i64 1
%5 = load i32, i32* %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %5)
%7 = add i32 %2, -2
%8 = icmp sgt i32 %2, 2
br i1 %8, label %9, label %25
9: ; preds = %3
%10 = getelementptr inbounds i32, i32* %1, i64 2
br label %11
11: ; preds = %9, %18
%12 = phi i32* [ %19, %18 ], [ %10, %9 ]
%13 = phi i32 [ %23, %18 ], [ 0, %9 ]
%14 = and i32 %13, 7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = getelementptr inbounds i32, i32* %12, i64 1
%20 = load i32, i32* %12
%21 = add nsw i32 %20, -1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i32 %13, 1
%24 = icmp eq i32 %23, %7
br i1 %24, label %25, label %11
25: ; preds = %18, %3
ret void
}