#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*/ printf(char *, unsigned char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
void dump_frame(unsigned char *data, int len) {
  int i, j, k;
  unsigned char buf[50];
  for (k = 0; k < len; k += 16) {
    for (i = k, j = 0; (i < (k + 16)) && (i < len); i++, j += 3)
      sprintf((char *)&buf[j], "%02X ", data[i]);
    buf[j] = '\0';
    printf("%s", buf);
  }
}


x86 assembly (clang, -O0):
<dump_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e2 <dump_frame+0xc2>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%edx
add    $0x10,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x51(%rbp)
jge    1171 <dump_frame+0x51>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1181 <dump_frame+0x61>
jmp    11bb <dump_frame+0x9b>
movslq -0x14(%rbp),%rax
lea    -0x50(%rbp),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xe65(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <dump_frame+0x2f>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <dump_frame+0x16>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_frame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %esi,%esi
jle    11ab <dump_frame+0x8b>
mov    %esi,%ebx
mov    %rdi,%r14
mov    $0x1,%r13d
xor    %r15d,%r15d
lea    0x10(%rsp),%rbp
lea    0xeb4(%rip),%r12
jmp    1176 <dump_frame+0x56>
xchg   %ax,%ax
movb   $0x0,0x0(%rbp)
lea    0xeab(%rip),%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <printf@plt>
mov    0x8(%rsp),%r13
add    $0x10,%r13
cmp    %ebx,%r15d
jge    11ab <dump_frame+0x8b>
add    $0x10,%r15
mov    %r13,0x8(%rsp)
nop
movzbl -0x1(%r14,%r13,1),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <sprintf@plt>
add    $0x3,%rbp
cmp    %r15,%r13
jae    1150 <dump_frame+0x30>
mov    %r13,%rax
add    $0x1,%rax
cmp    %ebx,%r13d
mov    %rax,%r13
jl     1180 <dump_frame+0x60>
jmp    1150 <dump_frame+0x30>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%02X \00"
@.str.1 = [3 x i8] c"%s\00"
define void @dump_frame(i8* nocapture %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %28
6: ; preds = %2, %22
%7 = phi i64 [ %8, %22 ], [ 0, %2 ]
%8 = add nuw i64 %7, 16
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ %7, %6 ], [ %16, %9 ]
%11 = phi i64 [ 0, %6 ], [ %17, %9 ]
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %11
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = load i8, i8* %13
%15 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 zeroext %14)
%16 = add nuw i64 %10, 1
%17 = add nuw nsw i64 %11, 3
%18 = icmp ult i64 %16, %8
%19 = trunc i64 %16 to i32
%20 = icmp slt i32 %19, %1
%21 = and i1 %18, %20
br i1 %21, label %9, label %22
22: ; preds = %9
%23 = and i64 %17, 4294967295
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%26 = trunc i64 %8 to i32
%27 = icmp slt i32 %26, %1
br i1 %27, label %6, label %28
28: ; preds = %22, %2
ret void
}