#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;
struct pkt_buff {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _ascii(int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ _hex(int /*<<< orphan*/ *, size_t);
size_t pkt_len(struct pkt_buff *);
int /*<<< orphan*/ *pkt_pull(struct pkt_buff *, size_t);
int /*<<< orphan*/ tprintf(char *);
void hex_ascii(struct pkt_buff *pkt) {
  size_t len = pkt_len(pkt);
  uint8_t *ptr = pkt_pull(pkt, len);
  if (len) {
    _ascii(ptr, len);
    _hex(ptr, len);
  }
  tprintf("\n");
}


x86 assembly (clang, -O0):
<hex_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <pkt_len@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <pkt_pull@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119f <hex_ascii+0x4f>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <_ascii@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <_hex@plt>
lea    0xe5a(%rip),%rdi
call   1050 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_ascii>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1070 <pkt_len@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <pkt_pull@plt>
test   %rbx,%rbx
je     1188 <hex_ascii+0x38>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <_ascii@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <_hex@plt>
lea    0xe71(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <tprintf@plt>

LLVM IR (-O0):
%struct.pkt_buff = type { i32 }
@.str = [2 x i8] c"\0A\00"
define void @hex_ascii(%struct.pkt_buff* %0) {
%2 = alloca %struct.pkt_buff*
%3 = alloca i64
%4 = alloca i32*
store %struct.pkt_buff* %0, %struct.pkt_buff** %2
%5 = load %struct.pkt_buff*, %struct.pkt_buff** %2
%6 = call i64 @pkt_len(%struct.pkt_buff* %5)
store i64 %6, i64* %3
%7 = load %struct.pkt_buff*, %struct.pkt_buff** %2
%8 = load i64, i64* %3
%9 = call i32* @pkt_pull(%struct.pkt_buff* %7, i64 %8)
store i32* %9, i32** %4
%10 = load i64, i64* %3
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %1
%13 = load i32*, i32** %4
%14 = load i64, i64* %3
%15 = call i32 @_ascii(i32* %13, i64 %14)
%16 = load i32*, i32** %4
%17 = load i64, i64* %3
%18 = call i32 @_hex(i32* %16, i64 %17)
br label %19
19: ; preds = %12, %1
%20 = call i32 @tprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.pkt_buff = type { i32 }
@.str = [2 x i8] c"\0A\00"
define void @hex_ascii(%struct.pkt_buff* %0) {
%2 = tail call i64 @pkt_len(%struct.pkt_buff* %0)
%3 = tail call i32* @pkt_pull(%struct.pkt_buff* %0, i64 %2)
%4 = icmp eq i64 %2, 0
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @_ascii(i32* %3, i64 %2)
%7 = tail call i32 @_hex(i32* %3, i64 %2)
br label %8
8: ; preds = %5, %1
%9 = tail call i32 @tprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}