#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*/ logMsg(char *, ...);
int logHex(int a_iLen, void *a_pData) {
  int i, iByte;
  char *pData = a_pData;
  for (i = 0; i < a_iLen; i++) {
    if ((i % 32) == 0) {
      if (a_iLen > 32) {
        logMsg("\n\t");
      }
    } else if ((i % 4) == 0) {
      logMsg(" ");
    }
    iByte = pData[i];
    iByte &= 0x000000ff;
    logMsg("%02x", iByte);
  }
  logMsg("\n");
  return a_iLen;
}


x86 assembly (clang, -O0):
<logHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cb <logHex+0xbb>
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116b <logHex+0x5b>
cmpl   $0x20,-0x4(%rbp)
jle    1166 <logHex+0x56>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <logMsg@plt>
jmp    1192 <logHex+0x82>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118d <logHex+0x7d>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <logMsg@plt>
jmp    1192 <logHex+0x82>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <logMsg@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <logHex+0x1e>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <logMsg@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
test   %edi,%edi
jle    117f <logHex+0x6f>
mov    %rsi,%rbx
mov    %r14d,%ebp
lea    0xed6(%rip),%r15
lea    0xecd(%rip),%r13
xor    %r12d,%r12d
jmp    115f <logHex+0x4f>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <logMsg@plt>
movzbl (%rbx,%r12,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <logMsg@plt>
add    $0x1,%r12
cmp    %r12,%rbp
je     117f <logHex+0x6f>
test   $0x1f,%r12b
je     1170 <logHex+0x60>
mov    %r13,%rdi
test   $0x3,%r12b
jne    1147 <logHex+0x37>
jmp    1140 <logHex+0x30>
lea    0xe89(%rip),%rdi
cmp    $0x20,%r14d
ja     1140 <logHex+0x30>
jmp    1147 <logHex+0x37>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1030 <logMsg@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\09\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @logHex(i32 returned %0, i8* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = icmp ugt i32 %0, 32
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %4, %19
%8 = phi i64 [ 0, %4 ], [ %24, %19 ]
%9 = trunc i64 %8 to i32
%10 = and i32 %9, 31
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
br i1 %5, label %16, label %19
13: ; preds = %7
%14 = and i32 %9, 3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %12
%17 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %12 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %13 ]
%18 = tail call i32 (i8*, ...) @logMsg(i8* %17)
br label %19
19: ; preds = %16, %13, %12
%20 = getelementptr inbounds i8, i8* %1, i64 %8
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @logMsg(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i64 %8, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %7
26: ; preds = %19, %2
%27 = tail call i32 (i8*, ...) @logMsg(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 %0
}