#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_showmem_line(char *, int);
int my_showmem(char *str, int size) {
  int i;
  int l;
  i = 0;
  while (i < size) {
    l = size - i;
    if (l > 16) {
      l = 16;
    }
    my_showmem_line(str + i, l);
    i = i + 16;
  }
  return (0);
}


x86 assembly (clang, -O0):
<my_showmem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <my_showmem+0x5d>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jle    114c <my_showmem+0x3c>
movl   $0x10,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0x14(%rbp),%esi
call   1030 <my_showmem_line@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <my_showmem+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_showmem>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1150 <my_showmem+0x40>
mov    %esi,%r15d
mov    %rdi,%r14
xor    %ebx,%ebx
mov    %esi,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x10,%ebp
mov    $0x10,%esi
cmovl  %ebp,%esi
lea    (%r14,%rbx,1),%rdi
call   1030 <my_showmem_line@plt>
add    $0x10,%rbx
add    $0xfffffff0,%ebp
cmp    %r15d,%ebx
jl     1130 <my_showmem+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_showmem(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = sub nsw i32 %12, %13
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 16
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 16, i32* %6
br label %18
18: ; preds = %17, %11
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i32, i32* %6
%24 = call i32 @my_showmem_line(i8* %22, i32 %23)
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 16
store i32 %26, i32* %5
br label %7
27: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
define i32 @my_showmem(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2, %4
%5 = phi i64 [ %12, %4 ], [ 0, %2 ]
%6 = trunc i64 %5 to i32
%7 = sub nsw i32 %1, %6
%8 = icmp slt i32 %7, 16
%9 = select i1 %8, i32 %7, i32 16
%10 = getelementptr inbounds i8, i8* %0, i64 %5
%11 = tail call i32 @my_showmem_line(i8* %10, i32 %9)
%12 = add nuw i64 %5, 16
%13 = trunc i64 %12 to i32
%14 = icmp slt i32 %13, %1
br i1 %14, label %4, label %15
15: ; preds = %4, %2
ret i32 0
}