#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*/ my_putchar(char);
void my_showmem_line_hex(char *str, int size) {
  char *hexbase;
  int i;
  hexbase = "0123456789abcdef";
  i = 0;
  while (i < size) {
    my_putchar(hexbase[(*(str + i) / 16) % 16]);
    my_putchar(hexbase[*(str + i) % 16]);
    if (i % 2 == 1)
      my_putchar(' ');
    i = i + 1;
  }
  while (i < 16) {
    my_putchar(' ');
    my_putchar(' ');
    if (i % 2 == 1)
      my_putchar(' ');
    i = i + 1;
  }
}


x86 assembly (clang, -O0):
<my_showmem_line_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <my_showmem_line_hex+0xb9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11bb <my_showmem_line_hex+0xab>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <my_showmem_line_hex+0x21>
jmp    11ce <my_showmem_line_hex+0xbe>
cmpl   $0x10,-0x1c(%rbp)
jge    1218 <my_showmem_line_hex+0x108>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    120a <my_showmem_line_hex+0xfa>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ce <my_showmem_line_hex+0xbe>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_showmem_line_hex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    119a <my_showmem_line_hex+0x8a>
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
lea    0xed3(%rip),%r12
jmp    1139 <my_showmem_line_hex+0x29>
nop
add    $0x1,%rbx
cmp    %rbx,%r15
je     118c <my_showmem_line_hex+0x7c>
movzbl (%r14,%rbx,1),%eax
mov    %eax,%ecx
sar    $0x7,%cl
shr    $0x4,%cl
add    %al,%cl
sar    $0x4,%cl
movsbq %cl,%rax
movsbl (%rax,%r12,1),%edi
call   1030 <my_putchar@plt>
movzbl (%r14,%rbx,1),%eax
mov    %eax,%ecx
sar    $0x7,%cl
shr    $0x4,%cl
add    %al,%cl
and    $0xf0,%cl
sub    %cl,%al
movsbq %al,%rax
movsbl (%rax,%r12,1),%edi
call   1030 <my_putchar@plt>
test   $0x1,%bl
je     1130 <my_showmem_line_hex+0x20>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
jmp    1130 <my_showmem_line_hex+0x20>
cmp    $0xf,%ebp
jbe    11a8 <my_showmem_line_hex+0x98>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
jmp    11a8 <my_showmem_line_hex+0x98>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x10,%ebp
je     1191 <my_showmem_line_hex+0x81>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
test   $0x1,%bpl
je     11a0 <my_showmem_line_hex+0x90>
mov    $0x20,%edi
call   1030 <my_putchar@plt>
jmp    11a0 <my_showmem_line_hex+0x90>

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @my_showmem_line_hex(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %42, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = sdiv i32 %18, 16
%20 = srem i32 %19, 16
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %12, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @my_putchar(i8 signext %23)
%25 = load i8*, i8** %5
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = srem i32 %31, 16
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %25, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @my_putchar(i8 signext %35)
%37 = load i32, i32* %6
%38 = srem i32 %37, 2
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %11
%41 = call i32 @my_putchar(i8 signext 32)
br label %42
42: ; preds = %40, %11
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %7
45: ; preds = %7
br label %46
46: ; preds = %57, %45
%47 = load i32, i32* %6
%48 = icmp slt i32 %47, 16
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = call i32 @my_putchar(i8 signext 32)
%51 = call i32 @my_putchar(i8 signext 32)
%52 = load i32, i32* %6
%53 = srem i32 %52, 2
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %57
55: ; preds = %49
%56 = call i32 @my_putchar(i8 signext 32)
br label %57
57: ; preds = %55, %49
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %46
60: ; preds = %46
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
define void @my_showmem_line_hex(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %10
6: ; preds = %29
%7 = icmp ult i32 %1, 16
br i1 %7, label %8, label %43
8: ; preds = %2, %6
%9 = phi i32 [ 0, %2 ], [ %1, %6 ]
br label %32
10: ; preds = %4, %29
%11 = phi i64 [ 0, %4 ], [ %30, %29 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = sdiv i8 %13, 16
%15 = sext i8 %14 to i64
%16 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @my_putchar(i8 signext %17)
%19 = load i8, i8* %12
%20 = srem i8 %19, 16
%21 = sext i8 %20 to i64
%22 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = tail call i32 @my_putchar(i8 signext %23)
%25 = and i64 %11, 1
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %10
%28 = tail call i32 @my_putchar(i8 signext 32)
br label %29
29: ; preds = %27, %10
%30 = add nuw nsw i64 %11, 1
%31 = icmp eq i64 %30, %5
br i1 %31, label %6, label %10
32: ; preds = %8, %40
%33 = phi i32 [ %41, %40 ], [ %9, %8 ]
%34 = tail call i32 @my_putchar(i8 signext 32)
%35 = tail call i32 @my_putchar(i8 signext 32)
%36 = and i32 %33, 1
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %32
%39 = tail call i32 @my_putchar(i8 signext 32)
br label %40
40: ; preds = %38, %32
%41 = add nuw i32 %33, 1
%42 = icmp eq i32 %41, 16
br i1 %42, label %43, label %32
43: ; preds = %40, %6
ret void
}