#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_out_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 * 20 * 4)]);
    if ((i % 4) == 3)
      printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_out_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    11ae <dump_out_shammx+0x9e>
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
imul   $0x14,%edx,%edx
shl    $0x2,%edx
add    %edx,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    119b <dump_out_shammx+0x8b>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <dump_out_shammx+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <dump_out_shammx+0x19>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_out_shammx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %esi,%esi
je     119d <dump_out_shammx+0x7d>
mov    %esi,%r12d
shl    $0x2,%edx
mov    %edx,%r13d
and    $0xc,%r13d
and    $0xfffffff0,%edx
lea    (%rdx,%rdx,4),%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    115c <dump_out_shammx+0x3c>
nopl   (%rax)
add    $0x1,%r15d
add    $0x4,%ebp
cmp    %r15d,%r12d
je     119d <dump_out_shammx+0x7d>
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    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x3,%r14d
jne    1150 <dump_out_shammx+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1150 <dump_out_shammx+0x30>
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_out_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 = %41, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %44
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, 20
%28 = mul i32 %27, 4
%29 = add i32 %24, %28
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %13, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %7
%36 = urem i32 %35, 4
%37 = icmp eq i32 %36, 3
br i1 %37, label %38, label %40
38: ; preds = %12
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %12
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add i32 %42, 1
store i32 %43, i32* %7
br label %8
44: ; preds = %8
%45 = 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_out_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 = lshr i32 %2, 2
%9 = mul i32 %8, 80
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
}