#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*/ g_print(char *, ...);
void printbuf(char *buf, int size) {
  int i;
  for (i = 0; i < size; i++) {
    if ((i & 0xf) == 0)
      g_print("%06x: ", i);
    g_print("%02x ", buf[i]);
    if ((i & 0xf) == 0xf)
      g_print("\n");
  }
  g_print("\n");
}


x86 assembly (clang, -O0):
<printbuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <printbuf+0x8c>
mov    -0x10(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1152 <printbuf+0x42>
mov    -0x10(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <g_print@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <g_print@plt>
mov    -0x10(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    1189 <printbuf+0x79>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <g_print@plt>
jmp    118e <printbuf+0x7e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <printbuf+0x16>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <g_print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbuf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1194 <printbuf+0x84>
mov    %rdi,%r13
mov    %esi,%ebp
lea    0xed5(%rip),%r14
lea    0xed5(%rip),%r15
xor    %ebx,%ebx
jmp    1165 <printbuf+0x55>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <g_print@plt>
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <g_print@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1194 <printbuf+0x84>
mov    %ebx,%r12d
and    $0xf,%r12d
je     1140 <printbuf+0x30>
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <g_print@plt>
cmp    $0xf,%r12d
jne    115c <printbuf+0x4c>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1030 <g_print@plt>
jmp    115c <printbuf+0x4c>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <g_print@plt>

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

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