#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*/ ft_putnbr_hex(unsigned char const, int);
int /*<<< orphan*/ write(int, ...);
void ft_memprint(const void *addr, size_t size) {
  size_t c;
  size_t i;
  const unsigned char *ptr;
  i = 0;
  while (i < size) {
    ptr = addr + i;
    c = -1;
    while (++c < 16 && c + i < size) {
      ft_putnbr_hex(*(ptr + c), 2);
      (c % 2) ? (write(1, " ", 1)) : 0;
    }
    while (++c < 17)
      (c % 2) ? (write(1, "  ", 2)) : (write(1, "   ", 3));
    c = -1;
    while (++c < 16 && c + i < size)
      (32 <= *(ptr + c) && *(ptr + c) <= 126) ? (write(1, ptr + c, 1))
                                              : write(1, ".", 1);
    write(1, "\n", 1);
    i += 16;
  }
}


x86 assembly (clang, -O0):
<ft_memprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1318 <ft_memprint+0x1f8>
mov    -0x8(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x10,%rcx
mov    %al,-0x29(%rbp)
jae    1187 <ft_memprint+0x67>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
setb   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1197 <ft_memprint+0x77>
jmp    11e3 <ft_memprint+0xc3>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
movzbl (%rax,%rcx,1),%edi
call   1030 <ft_putnbr_hex@plt>
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11d9 <ft_memprint+0xb9>
mov    $0x1,%edx
lea    0xe37(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1040 <write@plt>
jmp    11de <ft_memprint+0xbe>
jmp    11de <ft_memprint+0xbe>
jmp    115a <ft_memprint+0x3a>
jmp    11e8 <ft_memprint+0xc8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmp    $0x11,%rax
jae    124a <ft_memprint+0x12a>
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     122d <ft_memprint+0x10d>
mov    $0x1,%edi
lea    0xde5(%rip),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1040 <write@plt>
jmp    1245 <ft_memprint+0x125>
mov    $0x1,%edi
lea    0xdc7(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1040 <write@plt>
jmp    11e8 <ft_memprint+0xc8>
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x10,%rcx
mov    %al,-0x2a(%rbp)
jae    127f <ft_memprint+0x15f>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
setb   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    128f <ft_memprint+0x16f>
jmp    12f2 <ft_memprint+0x1d2>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jg     12d8 <ft_memprint+0x1b8>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     12d8 <ft_memprint+0x1b8>
mov    -0x28(%rbp),%rsi
add    -0x18(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
mov    $0x0,%al
call   1040 <write@plt>
jmp    12ed <ft_memprint+0x1cd>
mov    $0x1,%edx
lea    0xd20(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1040 <write@plt>
jmp    1252 <ft_memprint+0x132>
mov    $0x1,%edx
lea    0xd08(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1040 <write@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <ft_memprint+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_memprint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1272 <ft_memprint+0x152>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%r15d
lea    0xebb(%rip),%r13
xor    %eax,%eax
jmp    1181 <ft_memprint+0x61>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
lea    0xeaa(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
mov    (%rsp),%rax
add    $0x10,%rax
add    $0x10,%r15
add    $0x10,%rbx
cmp    %r14,%rax
jae    1272 <ft_memprint+0x152>
mov    %rax,(%rsp)
mov    $0x2,%ecx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rcx,%r12
movzbl (%rbx,%rbp,1),%edi
mov    $0x2,%esi
call   1030 <ft_putnbr_hex@plt>
test   $0x1,%bpl
je     11bb <ft_memprint+0x9b>
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
lea    0x1(%rbp),%rax
cmp    $0xe,%rbp
ja     11d5 <ft_memprint+0xb5>
add    %r15,%rbp
lea    0x1(%r12),%rcx
cmp    %r14,%rbp
mov    %rax,%rbp
jb     1190 <ft_memprint+0x70>
add    $0xffffffffffffffff,%rax
cmp    $0xe,%rax
lea    0xe1c(%rip),%rbp
jbe    1259 <ft_memprint+0x139>
xor    %ebp,%ebp
lea    0xe15(%rip),%r12
nop
movzbl (%rbx,%rbp,1),%eax
add    $0xe0,%al
cmp    $0x5e,%al
ja     1210 <ft_memprint+0xf0>
lea    (%rbx,%rbp,1),%rsi
mov    $0x1,%edi
jmp    1218 <ft_memprint+0xf8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
cmp    $0xe,%rbp
ja     1150 <ft_memprint+0x30>
lea    (%r15,%rbp,1),%rax
add    $0x1,%rbp
cmp    %r14,%rax
jb     11f0 <ft_memprint+0xd0>
jmp    1150 <ft_memprint+0x30>
mov    %rbp,%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <write@plt>
add    $0x1,%r12
cmp    $0x11,%r12
je     11e6 <ft_memprint+0xc6>
mov    $0x1,%edi
test   $0x1,%r12b
je     1240 <ft_memprint+0x120>
lea    0xd96(%rip),%rsi
mov    $0x2,%edx
jmp    1248 <ft_memprint+0x128>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @ft_memprint(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %6
br label %8
8: ; preds = %93, %2
%9 = load i64, i64* %6
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %97
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i64, i64* %6
%15 = getelementptr i8, i8* %13, i64 %14
store i8* %15, i8** %7
store i64 -1, i64* %5
br label %16
16: ; preds = %40, %12
%17 = load i64, i64* %5
%18 = add i64 %17, 1
store i64 %18, i64* %5
%19 = icmp ult i64 %18, 16
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i64, i64* %5
%22 = load i64, i64* %6
%23 = add i64 %21, %22
%24 = load i64, i64* %4
%25 = icmp ult i64 %23, %24
br label %26
26: ; preds = %20, %16
%27 = phi i1 [ false, %16 ], [ %25, %20 ]
br i1 %27, label %28, label %42
28: ; preds = %26
%29 = load i8*, i8** %7
%30 = load i64, i64* %5
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @ft_putnbr_hex(i8 zeroext %32, i32 2)
%34 = load i64, i64* %5
%35 = urem i64 %34, 2
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %40
39: ; preds = %28
br label %40
40: ; preds = %39, %37
%41 = phi i32 [ %38, %37 ], [ 0, %39 ]
br label %16
42: ; preds = %26
br label %43
43: ; preds = %55, %42
%44 = load i64, i64* %5
%45 = add i64 %44, 1
store i64 %45, i64* %5
%46 = icmp ult i64 %45, 17
br i1 %46, label %47, label %57
47: ; preds = %43
%48 = load i64, i64* %5
%49 = urem i64 %48, 2
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %55
53: ; preds = %47
%54 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %55
55: ; preds = %53, %51
%56 = phi i32 [ %52, %51 ], [ %54, %53 ]
br label %43
57: ; preds = %43
store i64 -1, i64* %5
br label %58
58: ; preds = %91, %57
%59 = load i64, i64* %5
%60 = add i64 %59, 1
store i64 %60, i64* %5
%61 = icmp ult i64 %60, 16
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load i64, i64* %5
%64 = load i64, i64* %6
%65 = add i64 %63, %64
%66 = load i64, i64* %4
%67 = icmp ult i64 %65, %66
br label %68
68: ; preds = %62, %58
%69 = phi i1 [ false, %58 ], [ %67, %62 ]
br i1 %69, label %70, label %93
70: ; preds = %68
%71 = load i8*, i8** %7
%72 = load i64, i64* %5
%73 = getelementptr inbounds i8, i8* %71, i64 %72
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = icmp sle i32 32, %75
br i1 %76, label %77, label %89
77: ; preds = %70
%78 = load i8*, i8** %7
%79 = load i64, i64* %5
%80 = getelementptr inbounds i8, i8* %78, i64 %79
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = icmp sle i32 %82, 126
br i1 %83, label %84, label %89
84: ; preds = %77
%85 = load i8*, i8** %7
%86 = load i64, i64* %5
%87 = getelementptr inbounds i8, i8* %85, i64 %86
%88 = call i32 (i32, ...) @write(i32 1, i8* %87, i32 1)
br label %91
89: ; preds = %77, %70
%90 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %91
91: ; preds = %89, %84
%92 = phi i32 [ %88, %84 ], [ %90, %89 ]
br label %58
93: ; preds = %68
%94 = call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%95 = load i64, i64* %6
%96 = add i64 %95, 16
store i64 %96, i64* %6
br label %8
97: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @ft_memprint(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %56, label %4
4: ; preds = %2, %52
%5 = phi i64 [ %54, %52 ], [ 0, %2 ]
%6 = getelementptr i8, i8* %0, i64 %5
br label %9
7: ; preds = %18
%8 = icmp ult i64 %10, 15
br i1 %8, label %24, label %35
9: ; preds = %4, %18
%10 = phi i64 [ %19, %18 ], [ 0, %4 ]
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @ft_putnbr_hex(i8 zeroext %12, i32 2)
%14 = and i64 %10, 1
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %18
18: ; preds = %9, %16
%19 = add nuw nsw i64 %10, 1
%20 = icmp ult i64 %10, 15
%21 = add nuw i64 %19, %5
%22 = icmp ult i64 %21, %1
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %9, label %7
24: ; preds = %7, %33
%25 = phi i64 [ %26, %33 ], [ %19, %7 ]
%26 = add nuw nsw i64 %25, 1
%27 = and i64 %26, 1
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %24
%30 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %33
31: ; preds = %24
%32 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %33
33: ; preds = %31, %29
%34 = icmp eq i64 %26, 16
br i1 %34, label %35, label %24
35: ; preds = %33, %7
br label %36
36: ; preds = %35, %46
%37 = phi i64 [ %47, %46 ], [ 0, %35 ]
%38 = getelementptr inbounds i8, i8* %6, i64 %37
%39 = load i8, i8* %38
%40 = add i8 %39, -32
%41 = icmp ult i8 %40, 95
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = tail call i32 (i32, ...) @write(i32 1, i8* %38, i32 1)
br label %46
44: ; preds = %36
%45 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %46
46: ; preds = %44, %42
%47 = add nuw nsw i64 %37, 1
%48 = icmp ult i64 %37, 15
%49 = add nuw i64 %47, %5
%50 = icmp ult i64 %49, %1
%51 = select i1 %48, i1 %50, i1 false
br i1 %51, label %36, label %52
52: ; preds = %46
%53 = tail call i32 (i32, ...) @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%54 = add i64 %5, 16
%55 = icmp ult i64 %54, %1
br i1 %55, label %4, label %56
56: ; preds = %52, %2
ret void
}