#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 *, void *, unsigned char, unsigned char);
void print_function_instructions(void *func_ptr, size_t func_len) {
  for (unsigned char i = 0; i < func_len; i++) {
    unsigned char *instruction = (unsigned char *)func_ptr + i;
    printf("%p (%2u): %x\n", func_ptr + i, i, *instruction);
  }
}


x86 assembly (clang, -O0):
<print_function_instructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    -0x10(%rbp),%rax
jae    1177 <print_function_instructions+0x67>
mov    -0x8(%rbp),%rax
movzbl -0x11(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
movzbl -0x11(%rbp),%eax
cltq
add    %rax,%rsi
mov    -0x11(%rbp),%cl
mov    -0x20(%rbp),%rax
lea    0xea1(%rip),%rdi
movzbl %cl,%edx
movzbl (%rax),%ecx
call   1030 <printf@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1124 <print_function_instructions+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_function_instructions>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     114f <print_function_instructions+0x3f>
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
lea    0xed4(%rip),%r15
nopl   0x0(%rax)
lea    (%r12,%rbx,1),%rsi
movzbl (%r12,%rbx,1),%ecx
movzbl %bl,%edx
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%ebx
movzbl %bl,%ebx
cmp    %r14,%rbx
jb     1130 <print_function_instructions+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%p (%2u): %x\0A\00"
define void @print_function_instructions(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8 0, i8* %5
br label %7
7: ; preds = %27, %2
%8 = load i8, i8* %5
%9 = zext i8 %8 to i64
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %5
%15 = zext i8 %14 to i32
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
store i8* %17, i8** %6
%18 = load i8*, i8** %3
%19 = load i8, i8* %5
%20 = zext i8 %19 to i32
%21 = sext i32 %20 to i64
%22 = getelementptr i8, i8* %18, i64 %21
%23 = load i8, i8* %5
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %22, i8 zeroext %23, i8 zeroext %25)
br label %27
27: ; preds = %12
%28 = load i8, i8* %5
%29 = add i8 %28, 1
store i8 %29, i8* %5
br label %7
30: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%p (%2u): %x\0A\00"
define void @print_function_instructions(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %5
4: ; preds = %5, %2
ret void
5: ; preds = %2, %5
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = trunc i64 %6 to i8
%8 = getelementptr inbounds i8, i8* %0, i64 %6
%9 = load i8, i8* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8, i8 zeroext %7, i8 zeroext %9)
%11 = add nuw nsw i64 %6, 1
%12 = and i64 %11, 255
%13 = icmp ult i64 %12, %1
br i1 %13, label %5, label %4
}