#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*/ ax25_dump(unsigned char *, int, int);
int /*<<< orphan*/ lprintf(int, char *, ...);
void ki_dump(unsigned char *data, int length, int hexdump) {
  int type;
  int val;
  type = data[0] & 0xf;
  if (type == 0) {
    ax25_dump(data + 1, length - 1, hexdump);
    return;
  }
  val = data[1];
  switch (type) {
  case 1:
    lprintf(3, "TX Delay: %lu ms\n", val * 10L);
    break;
  case 2:
    lprintf(3, "Persistence: %u/256\n", val + 1);
    break;
  case 3:
    lprintf(3, "Slot time: %lu ms\n", val * 10L);
    break;
  case 4:
    lprintf(3, "TX Tail time: %lu ms\n", val * 10L);
    break;
  case 5:
    lprintf(3, "Duplex: %s\n", val == 0 ? "Half" : "Full");
    break;
  case 6:
    lprintf(3, "Hardware %u\n", val);
    break;
  case 15:
    lprintf(3, "RETURN\n");
    break;
  default:
    lprintf(3, "code %u arg %u\n", type, val);
    break;
  }
}


x86 assembly (clang, -O0):
<ki_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1164 <ki_dump+0x44>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <ax25_dump@plt>
jmp    1292 <ki_dump+0x172>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xe,%eax
ja     1279 <ki_dump+0x159>
mov    -0x20(%rbp),%rax
lea    0xe71(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq -0x18(%rbp),%rax
imul   $0xa,%rax,%rdx
mov    $0x3,%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
mov    -0x18(%rbp),%edx
add    $0x1,%edx
mov    $0x3,%edi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
movslq -0x18(%rbp),%rax
imul   $0xa,%rax,%rdx
mov    $0x3,%edi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
movslq -0x18(%rbp),%rax
imul   $0xa,%rax,%rdx
mov    $0x3,%edi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
mov    -0x18(%rbp),%ecx
lea    0xe7d(%rip),%rdx
lea    0xe71(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
mov    $0x3,%edi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
mov    -0x18(%rbp),%edx
mov    $0x3,%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
mov    $0x3,%edi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
jmp    1292 <ki_dump+0x172>
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x3,%edi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1040 <lprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ki_dump>:
mov    %edx,%eax
movzbl (%rdi),%edx
add    $0x1,%rdi
and    $0xf,%edx
je     115f <ki_dump+0x3f>
movzbl (%rdi),%ecx
lea    -0x1(%rdx),%eax
cmp    $0xe,%eax
ja     11d4 <ki_dump+0xb4>
lea    0xebc(%rip),%rsi
movslq (%rsi,%rax,4),%rax
add    %rsi,%rax
jmp    *%rax
mov    %ecx,%eax
add    %rax,%rax
lea    (%rax,%rax,4),%rdx
lea    0xedf(%rip),%rsi
jmp    11b3 <ki_dump+0x93>
add    $0xffffffff,%esi
mov    %eax,%edx
jmp    1030 <ax25_dump@plt>
add    $0x1,%ecx
lea    0xedb(%rip),%rsi
jmp    11c6 <ki_dump+0xa6>
lea    (%rcx,%rcx,1),%rax
lea    (%rax,%rax,4),%rdx
lea    0xedf(%rip),%rsi
jmp    11b3 <ki_dump+0x93>
lea    (%rcx,%rcx,1),%rax
lea    (%rax,%rax,4),%rdx
lea    0xee1(%rip),%rsi
jmp    11b3 <ki_dump+0x93>
test   %rcx,%rcx
lea    0xef7(%rip),%rax
lea    0xef5(%rip),%rdx
cmove  %rax,%rdx
lea    0xed9(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
jmp    1040 <lprintf@plt>
lea    0xedc(%rip),%rsi
mov    $0x3,%edi
mov    %ecx,%edx
xor    %eax,%eax
jmp    1040 <lprintf@plt>
lea    0xedc(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
jmp    1040 <lprintf@plt>
lea    0xec1(%rip),%rsi
mov    $0x3,%edi
xor    %eax,%eax
jmp    1040 <lprintf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"TX Delay: %lu ms\0A\00"
@.str.1 = [21 x i8] c"Persistence: %u/256\0A\00"
@.str.2 = [19 x i8] c"Slot time: %lu ms\0A\00"
@.str.3 = [22 x i8] c"TX Tail time: %lu ms\0A\00"
@.str.4 = [12 x i8] c"Duplex: %s\0A\00"
@.str.5 = [5 x i8] c"Half\00"
@.str.6 = [5 x i8] c"Full\00"
@.str.7 = [13 x i8] c"Hardware %u\0A\00"
@.str.8 = [8 x i8] c"RETURN\0A\00"
@.str.9 = [16 x i8] c"code %u arg %u\0A\00"
define void @ki_dump(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 i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = and i32 %12, 15
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %6
%22 = call i32 @ax25_dump(i8* %18, i32 %20, i32 %21)
br label %63
23: ; preds = %3
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
store i32 %27, i32* %8
%28 = load i32, i32* %7
switch i32 %28, label %59 [
i32 1, label %29
i32 2, label %34
i32 3, label %38
i32 4, label %43
i32 5, label %48
i32 6, label %54
i32 15, label %57
]
29: ; preds = %23
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = mul nsw i64 %31, 10
%33 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %32)
br label %63
34: ; preds = %23
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
%37 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %63
38: ; preds = %23
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = mul nsw i64 %40, 10
%42 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %41)
br label %63
43: ; preds = %23
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = mul nsw i64 %45, 10
%47 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %46)
br label %63
48: ; preds = %23
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, 0
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0)
%53 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %63
54: ; preds = %23
%55 = load i32, i32* %8
%56 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %55)
br label %63
57: ; preds = %23
%58 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %63
59: ; preds = %23
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %60, i32 %61)
br label %63
63: ; preds = %16, %59, %57, %54, %48, %43, %38, %34, %29
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"TX Delay: %lu ms\0A\00"
@.str.1 = [21 x i8] c"Persistence: %u/256\0A\00"
@.str.2 = [19 x i8] c"Slot time: %lu ms\0A\00"
@.str.3 = [22 x i8] c"TX Tail time: %lu ms\0A\00"
@.str.4 = [12 x i8] c"Duplex: %s\0A\00"
@.str.5 = [5 x i8] c"Half\00"
@.str.6 = [5 x i8] c"Full\00"
@.str.7 = [13 x i8] c"Hardware %u\0A\00"
@.str.8 = [8 x i8] c"RETURN\0A\00"
@.str.9 = [16 x i8] c"code %u arg %u\0A\00"
define void @ki_dump(i8* %0, i32 %1, i32 %2) {
%4 = load i8, i8* %0
%5 = and i8 %4, 15
%6 = zext i8 %5 to i32
%7 = icmp eq i8 %5, 0
%8 = getelementptr inbounds i8, i8* %0, i64 1
br i1 %7, label %9, label %12
9: ; preds = %3
%10 = add nsw i32 %1, -1
%11 = tail call i32 @ax25_dump(i8* %8, i32 %10, i32 %2)
br label %40
12: ; preds = %3
%13 = load i8, i8* %8
%14 = zext i8 %13 to i32
switch i32 %6, label %38 [
i32 1, label %15
i32 2, label %19
i32 3, label %22
i32 4, label %26
i32 5, label %30
i32 6, label %34
i32 15, label %36
]
15: ; preds = %12
%16 = zext i8 %13 to i64
%17 = mul nuw nsw i64 %16, 10
%18 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %17)
br label %40
19: ; preds = %12
%20 = add nuw nsw i32 %14, 1
%21 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %40
22: ; preds = %12
%23 = zext i8 %13 to i64
%24 = mul nuw nsw i64 %23, 10
%25 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %24)
br label %40
26: ; preds = %12
%27 = zext i8 %13 to i64
%28 = mul nuw nsw i64 %27, 10
%29 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %28)
br label %40
30: ; preds = %12
%31 = icmp eq i8 %13, 0
%32 = select i1 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0)
%33 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %32)
br label %40
34: ; preds = %12
%35 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 %14)
br label %40
36: ; preds = %12
%37 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %40
38: ; preds = %12
%39 = tail call i32 (i32, i8*, ...) @lprintf(i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %6, i32 %14)
br label %40
40: ; preds = %15, %19, %22, %26, %30, %34, %36, %38, %9
ret void
}