#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printStringHexSymbols(void *bufferPtr, uint32_t length,
                           uint32_t lineLength) {
  unsigned char *symbolPtr = bufferPtr;
  for (uint32_t symbolCounter = 0; symbolCounter < length; symbolCounter++) {
    printf(" 0x%x ", *symbolPtr);
    if (lineLength > 0 && symbolCounter > 0) {
      if ((symbolCounter + 1) % lineLength == 0)
        printf("\n\r");
    }
    symbolPtr++;
  }
  printf("\r\n");
}


x86 assembly (clang, -O0):
<printStringHexSymbols>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <printStringHexSymbols+0x96>
mov    -0x18(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    118c <printStringHexSymbols+0x7c>
cmpl   $0x0,-0x1c(%rbp)
jle    118c <printStringHexSymbols+0x7c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1187 <printStringHexSymbols+0x77>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118c <printStringHexSymbols+0x7c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <printStringHexSymbols+0x21>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStringHexSymbols>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    118d <printStringHexSymbols+0x6d>
mov    %edx,%ebp
mov    %rdi,%r14
mov    %esi,%r13d
lea    0xec2(%rip),%r15
xor    %r12d,%r12d
jmp    1155 <printStringHexSymbols+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r12d,%r13d
je     118d <printStringHexSymbols+0x6d>
mov    %r12,%rbx
movzbl (%r14,%r12,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
test   %ebp,%ebp
jle    1150 <printStringHexSymbols+0x30>
test   %ebx,%ebx
je     1150 <printStringHexSymbols+0x30>
mov    %r12d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1150 <printStringHexSymbols+0x30>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1150 <printStringHexSymbols+0x30>
lea    0xe74(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [7 x i8] c" 0x%x \00"
@.str.1 = [3 x i8] c"\0A\0D\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @printStringHexSymbols(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
store i32 0, i32* %8
br label %10
10: ; preds = %36, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %39
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %14
%22 = load i32, i32* %8
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
%27 = load i32, i32* %6
%28 = srem i32 %26, %27
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
br label %33
33: ; preds = %32, %21, %14
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
br label %36
36: ; preds = %33
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %10
39: ; preds = %10
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c" 0x%x \00"
@.str.1 = [3 x i8] c"\0A\0D\00"
@str = [2 x i8] c"\0D\00"
define void @printStringHexSymbols(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br label %9
7: ; preds = %23, %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
9: ; preds = %5, %23
%10 = phi i32 [ 0, %5 ], [ %17, %23 ]
%11 = phi i8* [ %0, %5 ], [ %24, %23 ]
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp ne i32 %10, 0
%16 = select i1 %6, i1 %15, i1 false
%17 = add nuw nsw i32 %10, 1
br i1 %16, label %18, label %23
18: ; preds = %9
%19 = srem i32 %17, %2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %9, %18, %21
%24 = getelementptr inbounds i8, i8* %11, i64 1
%25 = icmp eq i32 %17, %1
br i1 %25, label %7, label %9
}