#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*/ log_redirect(int, char *, ...);
void dump_log(const void *nom_dump, unsigned int lng) {
  unsigned int i, j;
  unsigned int nbr_line;
  unsigned char car;
  nbr_line = (lng + 0x10 - 1) / 0x10;
  for (i = 0; (i < nbr_line); i++) {
    log_redirect((1 << 3), "%04X ", i * 0x10);
    for (j = 0; j < 0x10; j++) {
      if (i * 0x10 + j < lng) {
        car = *((const unsigned char *)nom_dump + i * 0x10 + j);
        log_redirect((1 << 3), "%02x", car);
      } else
        log_redirect((1 << 3), "  ");
      if (j % 4 == (4 - 1))
        log_redirect((1 << 3), " ");
    }
    log_redirect((1 << 3), "  ");
    for (j = 0; j < 0x10; j++) {
      if (i * 0x10 + j < lng) {
        car = *((const unsigned char *)nom_dump + i * 0x10 + j);
        if ((car < 32) || (car >= 127))
          log_redirect((1 << 3), ".");
        else
          log_redirect((1 << 3), "%c", car);
      } else
        log_redirect((1 << 3), "  ");
    }
    log_redirect((1 << 3), "\n");
  }
}


x86 assembly (clang, -O0):
<dump_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%eax
sub    $0x1,%eax
shr    $0x4,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    12dc <dump_log+0x1cc>
mov    -0x10(%rbp),%edx
shl    $0x4,%edx
mov    $0x8,%edi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jae    11f9 <dump_log+0xe9>
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b1 <dump_log+0xa1>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%edx
mov    $0x8,%edi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
jmp    11c4 <dump_log+0xb4>
mov    $0x8,%edi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    11e6 <dump_log+0xd6>
mov    $0x8,%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
jmp    11eb <dump_log+0xdb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <dump_log+0x51>
mov    $0x8,%edi
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jae    12bb <dump_log+0x1ab>
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1295 <dump_log+0x185>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jl     1261 <dump_log+0x151>
movzbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
jl     1279 <dump_log+0x169>
mov    $0x8,%edi
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
jmp    1290 <dump_log+0x180>
movzbl -0x19(%rbp),%edx
mov    $0x8,%edi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
jmp    12a8 <dump_log+0x198>
mov    $0x8,%edi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
jmp    12ad <dump_log+0x19d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1213 <dump_log+0x103>
mov    $0x8,%edi
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1030 <log_redirect@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <dump_log+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf(%rsi),%eax
mov    %rax,0x8(%rsp)
cmp    $0x10,%eax
jae    113a <dump_log+0x2a>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r15
mov    0x8(%rsp),%rax
shr    $0x4,%eax
mov    %rax,0x8(%rsp)
mov    %esi,%ebp
lea    0xeb3(%rip),%r12
lea    0xeb1(%rip),%r13
xor    %r14d,%r14d
xor    %eax,%eax
jmp    119e <dump_log+0x8e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x8,%edi
lea    0xe97(%rip),%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
mov    0x10(%rsp),%rax
add    $0x1,%rax
add    $0x10,%r15
add    $0x10,%r14
cmp    0x8(%rsp),%rax
mov    %rbx,%r12
je     112b <dump_log+0x1b>
mov    %rax,0x10(%rsp)
mov    %eax,%edx
shl    $0x4,%edx
mov    $0x8,%edi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
xor    %ebx,%ebx
jmp    11ca <dump_log+0xba>
nop
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1220 <dump_log+0x110>
lea    (%r14,%rbx,1),%rax
cmp    %rbp,%rax
jae    11f0 <dump_log+0xe0>
movzbl (%r15,%rbx,1),%edx
mov    $0x8,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
jmp    11ff <dump_log+0xef>
nopl   0x0(%rax)
mov    $0x8,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
mov    %ebx,%eax
not    %eax
test   $0x3,%al
jne    11c0 <dump_log+0xb0>
mov    $0x8,%edi
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
jmp    11c0 <dump_log+0xb0>
nopl   0x0(%rax)
mov    %r12,%rbx
mov    $0x8,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
xor    %r12d,%r12d
jmp    125d <dump_log+0x14d>
nopw   0x0(%rax,%rax,1)
mov    $0x8,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
add    $0x1,%r12
cmp    $0x10,%r12
je     1170 <dump_log+0x60>
lea    (%r14,%r12,1),%rax
cmp    %rbp,%rax
jae    1240 <dump_log+0x130>
movzbl (%r15,%r12,1),%edx
lea    -0x7f(%rdx),%eax
mov    $0x8,%edi
cmp    $0xa0,%al
ja     1280 <dump_log+0x170>
lea    0xd90(%rip),%rsi
jmp    1248 <dump_log+0x138>
lea    0xd89(%rip),%rsi
xor    %eax,%eax
call   1030 <log_redirect@plt>
jmp    124f <dump_log+0x13f>

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

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