#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 i;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_stuff_shammx(void *buf, unsigned int size, unsigned int index) {
  unsigned int i;
  for (i = 0; i < size; i++) {
    printf("%.2x",
           ((unsigned char *)
                buf)[((index & (4 - 1)) * 4 + ((i) & (0xffffffff - 3)) * 4 +
                      (3 - ((i)&3)) + (unsigned int)index / 4 * 16 * 4 * 4)]);
    if ((i % 4) == 3)
      printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_stuff_shammx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b1 <dump_stuff_shammx+0xa1>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
and    $0x3,%ecx
shl    $0x2,%ecx
mov    -0x14(%rbp),%edx
and    $0xfffffffc,%edx
shl    $0x2,%edx
add    %edx,%ecx
mov    -0x14(%rbp),%esi
and    $0x3,%esi
mov    $0x3,%edx
sub    %esi,%edx
add    %edx,%ecx
mov    -0x10(%rbp),%edx
shr    $0x2,%edx
shl    $0x4,%edx
shl    $0x2,%edx
shl    $0x2,%edx
add    %edx,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    119e <dump_stuff_shammx+0x8e>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a3 <dump_stuff_shammx+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <dump_stuff_shammx+0x19>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_stuff_shammx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %esi,%esi
je     11ad <dump_stuff_shammx+0x8d>
mov    %edx,%ebx
mov    %esi,%r12d
lea    0x0(,%rbx,4),%r13d
and    $0xc,%r13d
and    $0xfffffffc,%ebx
shl    $0x6,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    116c <dump_stuff_shammx+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0x4,%ebp
cmp    %r15d,%r12d
je     11ad <dump_stuff_shammx+0x8d>
mov    %ebp,%eax
and    $0xfffffff0,%eax
mov    %r15d,%r14d
and    $0x3,%r14d
mov    %r14d,%ecx
or     %r13d,%ecx
or     %eax,%ecx
xor    $0x3,%ecx
add    %ebx,%ecx
mov    (%rsp),%rax
movzbl (%rax,%rcx,1),%esi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x3,%r14d
jne    1160 <dump_stuff_shammx+0x40>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1160 <dump_stuff_shammx+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%.2x\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_stuff_shammx(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %42, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %45
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = and i32 %14, 3
%16 = mul i32 %15, 4
%17 = load i32, i32* %7
%18 = and i32 %17, -4
%19 = mul i32 %18, 4
%20 = add i32 %16, %19
%21 = load i32, i32* %7
%22 = and i32 %21, 3
%23 = sub i32 3, %22
%24 = add i32 %20, %23
%25 = load i32, i32* %6
%26 = udiv i32 %25, 4
%27 = mul i32 %26, 16
%28 = mul i32 %27, 4
%29 = mul i32 %28, 4
%30 = add i32 %24, %29
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %13, i64 %31
%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, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %7
%37 = urem i32 %36, 4
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %41
39: ; preds = %12
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %12
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add i32 %43, 1
store i32 %44, i32* %7
br label %8
45: ; preds = %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.2x\00"
define void @dump_stuff_shammx(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %30, label %5
5: ; preds = %3
%6 = shl i32 %2, 2
%7 = and i32 %6, 12
%8 = shl i32 %2, 6
%9 = and i32 %8, -256
br label %10
10: ; preds = %5, %27
%11 = phi i32 [ 0, %5 ], [ %28, %27 ]
%12 = shl i32 %11, 2
%13 = and i32 %12, -16
%14 = and i32 %11, 3
%15 = or i32 %14, %7
%16 = or i32 %15, %13
%17 = xor i32 %16, 3
%18 = add i32 %17, %9
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = icmp eq i32 %14, 3
br i1 %24, label %25, label %27
25: ; preds = %10
%26 = tail call i32 @putchar(i32 32)
br label %27
27: ; preds = %10, %25
%28 = add nuw i32 %11, 1
%29 = icmp eq i32 %28, %1
br i1 %29, label %30, label %10
30: ; preds = %27, %3
%31 = tail call i32 @putchar(i32 10)
ret void
}