#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_f(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
void log_f_dump(const char *text, void *data, unsigned size) {
  unsigned i;
  for (i = 0; i < size; i += 16) {
    unsigned j;
    char buf[1024];
    sprintf(buf, "%s %08x: ", text, i);
    for (j = 0; i + j < size && j < 16; ++j) {
      char nibble[16];
      sprintf(nibble, "%02x", ((unsigned char *)data)[i + j]);
      strcat(buf, nibble);
    }
    log_f("%s\n", buf);
  }
}


x86 assembly (clang, -O0):
<log_f_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    121a <log_f_dump+0xea>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%ecx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x431(%rbp)
jae    11a0 <log_f_dump+0x70>
cmpl   $0x10,-0x1c(%rbp)
setb   %al
mov    %al,-0x431(%rbp)
mov    -0x431(%rbp),%al
test   $0x1,%al
jne    11b3 <log_f_dump+0x83>
jmp    11f9 <log_f_dump+0xc9>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <log_f_dump+0x4c>
lea    -0x420(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1030 <log_f@plt>
mov    -0x18(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <log_f_dump+0x1d>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_f_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
mov    %edx,0x8(%rsp)
test   %edx,%edx
je     11fb <log_f_dump+0xcb>
mov    0x8(%rsp),%r15d
lea    0x30(%rsp),%rbx
lea    0x20(%rsp),%r12
xor    %ecx,%ecx
jmp    118c <log_f_dump+0x5c>
nopw   0x0(%rax,%rax,1)
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
call   1030 <log_f@plt>
mov    0xc(%rsp),%ecx
add    $0x10,%ecx
cmp    0x8(%rsp),%ecx
jae    11fb <log_f_dump+0xcb>
mov    %ecx,%r13d
mov    0x18(%rsp),%rax
lea    (%rax,%r13,1),%r14
add    $0x1,%r13
mov    %rbx,%rdi
lea    0xe5a(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %ecx,0xc(%rsp)
xor    %eax,%eax
call   1050 <sprintf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rbp,1),%edx
mov    %r12,%rdi
lea    0xe3b(%rip),%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
cmp    $0xe,%rbp
ja     1170 <log_f_dump+0x40>
mov    %r13,%rax
add    %rbp,%rax
add    $0x1,%rbp
cmp    %r15,%rax
jb     11c0 <log_f_dump+0x90>
jmp    1170 <log_f_dump+0x40>
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s %08x: \00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @log_f_dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca [16 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %11
11: ; preds = %51, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %54
15: ; preds = %11
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18)
store i32 0, i32* %8
br label %20
20: ; preds = %45, %15
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = add i32 %21, %22
%24 = load i32, i32* %6
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* %8
%28 = icmp ult i32 %27, 16
br label %29
29: ; preds = %26, %20
%30 = phi i1 [ false, %20 ], [ %28, %26 ]
br i1 %30, label %31, label %48
31: ; preds = %29
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = add i32 %34, %35
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%44 = call i32 @strcat(i8* %42, i8* %43)
br label %45
45: ; preds = %31
%46 = load i32, i32* %8
%47 = add i32 %46, 1
store i32 %47, i32* %8
br label %20
48: ; preds = %29
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = call i32 @log_f(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48
%52 = load i32, i32* %7
%53 = add i32 %52, 16
store i32 %53, i32* %7
br label %11
54: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s %08x: \00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @log_f_dump(i8* %0, i8* nocapture %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca [16 x i8]
%6 = icmp eq i32 %2, 0
br i1 %6, label %33, label %7
7: ; preds = %3
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %29, %7
%12 = phi i32 [ 0, %7 ], [ %31, %29 ]
%13 = zext i32 %12 to i64
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %12)
br label %15
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %23, %15 ]
%17 = phi i64 [ %13, %11 ], [ %25, %15 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @strcat(i8* %8, i8* %9)
%23 = add nuw nsw i64 %16, 1
%24 = add nuw nsw i64 %23, %13
%25 = add nuw nsw i64 %17, 1
%26 = icmp ult i64 %24, %10
%27 = icmp ult i64 %16, 15
%28 = and i1 %27, %26
br i1 %28, label %15, label %29
29: ; preds = %15
%30 = call i32 @log_f(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%31 = add i32 %12, 16
%32 = icmp ult i32 %31, %2
br i1 %32, label %11, label %33
33: ; preds = %29, %3
ret void
}