#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*/ RAW_FMT(int /*<<< orphan*/, char *, ...);
void _dbug_dump(unsigned short sr, void *pc, unsigned short *stack, int size) {
  int i;
  RAW_FMT(0, "%x : %x \t%x", 0, sr, (unsigned short)(((unsigned)pc) >> 16));
  for (i = 2; i < size; i++) {
    if ((i % 8) == 0)
      RAW_FMT(0, "\n%x :", i / 8);
    RAW_FMT(0, " %x\t", stack[i - 2]);
  }
  RAW_FMT(0, "\n");
}


x86 assembly (clang, -O0):
<_dbug_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movzwl -0x2(%rbp),%ecx
mov    -0x10(%rbp),%rax
shr    $0x10,%eax
movzwl %ax,%r8d
xor    %edx,%edx
lea    0xebe(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <RAW_FMT@plt>
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11be <_dbug_dump+0xae>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118f <_dbug_dump+0x7f>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
xor    %edi,%edi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <RAW_FMT@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movzwl (%rax,%rcx,2),%edx
xor    %edi,%edi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1030 <RAW_FMT@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <_dbug_dump+0x42>
xor    %edi,%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1030 <RAW_FMT@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dbug_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r12
mov    %rsi,%r8
mov    %edi,%ecx
shr    $0x10,%r8d
lea    0xed3(%rip),%rsi
xor    %edi,%edi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <RAW_FMT@plt>
cmp    $0x3,%ebp
jl     1193 <_dbug_dump+0x83>
mov    %ebp,%ebp
mov    $0x2,%ebx
lea    0xec1(%rip),%r14
lea    0xec0(%rip),%r15
jmp    117b <_dbug_dump+0x6b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzwl -0x4(%r12,%rbx,2),%edx
xor    %edi,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <RAW_FMT@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1193 <_dbug_dump+0x83>
test   $0x7,%bl
jne    1160 <_dbug_dump+0x50>
mov    %ebx,%edx
shr    $0x3,%edx
xor    %edi,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <RAW_FMT@plt>
jmp    1160 <_dbug_dump+0x50>
lea    0xe7d(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <RAW_FMT@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%x : %x \09%x\00"
@.str.1 = [6 x i8] c"\0A%x :\00"
@.str.2 = [5 x i8] c" %x\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @_dbug_dump(i16 zeroext %0, i8* %1, i16* %2, i32 %3) {
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i16*
%8 = alloca i32
%9 = alloca i32
store i16 %0, i16* %5
store i8* %1, i8** %6
store i16* %2, i16** %7
store i32 %3, i32* %8
%10 = load i16, i16* %5
%11 = zext i16 %10 to i32
%12 = load i8*, i8** %6
%13 = ptrtoint i8* %12 to i32
%14 = lshr i32 %13, 16
%15 = trunc i32 %14 to i16
%16 = zext i16 %15 to i32
%17 = call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0, i32 %11, i32 %16)
store i32 2, i32* %9
br label %18
18: ; preds = %39, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i32, i32* %9
%24 = srem i32 %23, 8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %9
%28 = sdiv i32 %27, 8
%29 = call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %22
%31 = load i16*, i16** %7
%32 = load i32, i32* %9
%33 = sub nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i16, i16* %31, i64 %34
%36 = load i16, i16* %35
%37 = zext i16 %36 to i32
%38 = call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %30
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %18
42: ; preds = %18
%43 = call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%x : %x \09%x\00"
@.str.1 = [6 x i8] c"\0A%x :\00"
@.str.2 = [5 x i8] c" %x\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @_dbug_dump(i16 zeroext %0, i8* %1, i16* nocapture %2, i32 %3) {
%5 = zext i16 %0 to i32
%6 = ptrtoint i8* %1 to i64
%7 = trunc i64 %6 to i32
%8 = lshr i32 %7, 16
%9 = tail call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0, i32 %5, i32 %8)
%10 = icmp sgt i32 %3, 2
br i1 %10, label %11, label %29
11: ; preds = %4
%12 = zext i32 %3 to i64
br label %13
13: ; preds = %11, %21
%14 = phi i64 [ 2, %11 ], [ %27, %21 ]
%15 = trunc i64 %14 to i32
%16 = and i32 %15, 7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = lshr i32 %15, 3
%20 = tail call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %13
%22 = add nsw i64 %14, -2
%23 = getelementptr inbounds i16, i16* %2, i64 %22
%24 = load i16, i16* %23
%25 = zext i16 %24 to i32
%26 = tail call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, %12
br i1 %28, label %29, label %13
29: ; preds = %21, %4
%30 = tail call i32 (i32, i8*, ...) @RAW_FMT(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}