#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 /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printHexBlocks(uint8_t *buffer, int size) {
  int i = 0;
  for (i = 0; i < size; i++) {
    if (i % 4 == 0) {
      if (i > 0) {
        printf("]");
      }
      printf("\n[");
    } else if (i > 0) {
      printf(":");
    }
    printf("%02hhx", buffer[i]);
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<printHexBlocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bc <printHexBlocks+0xac>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1178 <printHexBlocks+0x68>
cmpl   $0x0,-0x10(%rbp)
jle    1165 <printHexBlocks+0x55>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <printHexBlocks+0x85>
cmpl   $0x0,-0x10(%rbp)
jle    1190 <printHexBlocks+0x80>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <printHexBlocks+0x85>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <printHexBlocks+0x1d>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHexBlocks>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1166 <printHexBlocks+0x36>
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%ebp
jne    117a <printHexBlocks+0x4a>
lea    0xe9d(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe78(%rip),%r14
lea    0xe74(%rip),%r15
jmp    11c1 <printHexBlocks+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3a,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1166 <printHexBlocks+0x36>
test   $0x3,%bl
jne    11a0 <printHexBlocks+0x70>
mov    $0x5d,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11aa <printHexBlocks+0x7a>

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

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