#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_shammx64(void *buf, unsigned int size, unsigned int index) {
  unsigned int i;
  for (i = 0; i < size; i++) {
    printf("%.2x",
           ((unsigned char *)
                buf)[((index & (2 - 1)) * 8 + ((i) & (0xffffffff - 7)) * 2 +
                      (7 - ((i)&7)) + (unsigned int)index / 2 * 64 * 2)]);
    if ((i % 4) == 3)
      printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_out_shammx64>:
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_shammx64+0x9e>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
and    $0x1,%ecx
shl    $0x3,%ecx
mov    -0x14(%rbp),%edx
and    $0xfffffff8,%edx
shl    $0x1,%edx
add    %edx,%ecx
mov    -0x14(%rbp),%esi
and    $0x7,%esi
mov    $0x7,%edx
sub    %esi,%edx
add    %edx,%ecx
mov    -0x10(%rbp),%edx
shr    $0x1,%edx
shl    $0x6,%edx
shl    $0x1,%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_shammx64+0x8b>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <dump_out_shammx64+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <dump_out_shammx64+0x19>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_out_shammx64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1199 <dump_out_shammx64+0x79>
mov    %edx,%ebx
mov    %esi,%r12d
mov    %rdi,%r14
lea    0x0(,%rbx,8),%r13d
and    $0x8,%r13d
shl    $0x6,%ebx
and    $0xffffff80,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    115c <dump_out_shammx64+0x3c>
add    $0x1,%r15d
add    $0x2,%ebp
cmp    %r15d,%r12d
je     1199 <dump_out_shammx64+0x79>
mov    %ebp,%eax
and    $0xfffffff0,%eax
mov    %r15d,%ecx
and    $0x7,%ecx
or     %r13d,%ecx
or     %eax,%ecx
xor    $0x7,%ecx
add    %ebx,%ecx
movzbl (%r14,%rcx,1),%esi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%eax
not    %eax
test   $0x3,%al
jne    1150 <dump_out_shammx64+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1150 <dump_out_shammx64+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_shammx64(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, 1
%16 = mul i32 %15, 8
%17 = load i32, i32* %7
%18 = and i32 %17, -8
%19 = mul i32 %18, 2
%20 = add i32 %16, %19
%21 = load i32, i32* %7
%22 = and i32 %21, 7
%23 = sub i32 7, %22
%24 = add i32 %20, %23
%25 = load i32, i32* %6
%26 = udiv i32 %25, 2
%27 = mul i32 %26, 64
%28 = mul i32 %27, 2
%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_shammx64(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = shl i32 %2, 3
%7 = and i32 %6, 8
%8 = shl i32 %2, 6
%9 = and i32 %8, -128
br label %10
10: ; preds = %5, %28
%11 = phi i32 [ 0, %5 ], [ %29, %28 ]
%12 = shl i32 %11, 1
%13 = and i32 %12, -16
%14 = and i32 %11, 7
%15 = or i32 %14, %7
%16 = or i32 %15, %13
%17 = xor i32 %16, 7
%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 = and i32 %11, 3
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = tail call i32 @putchar(i32 32)
br label %28
28: ; preds = %10, %26
%29 = add nuw i32 %11, 1
%30 = icmp eq i32 %29, %1
br i1 %30, label %31, label %10
31: ; preds = %28, %3
%32 = tail call i32 @putchar(i32 10)
ret void
}