#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*/ outbuf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
char *display_variable_aux_data(unsigned char *buff) {
  static char outbuf[120];
  int j;
  if (buff[2] == 0x7f) {
    sprintf(outbuf, "func %12s : Data (hex)", "RFnoise");
  } else if (buff[2] == 0x7a) {
    sprintf(outbuf, "func %12s : Data (hex)", "RFrawdata");
  } else {
    sprintf(outbuf, "func %12s : Data (hex)", "RFunknown");
  }
  for (j = 0; j < buff[3]; j++) {
    snprintf(outbuf + strlen(outbuf), sizeof(outbuf) - strlen(outbuf) - 1,
             " %02x", buff[j + 4]);
  }
  return outbuf;
}


x86 assembly (clang, -O0):
<display_variable_aux_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x7f,%eax
jne    116c <display_variable_aux_data+0x3c>
lea    0x2efc(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    0xeb5(%rip),%rdx
call   1050 <sprintf@plt>
jmp    11bb <display_variable_aux_data+0x8b>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x7a,%eax
jne    119c <display_variable_aux_data+0x6c>
lea    0x2ecc(%rip),%rdi
lea    0xe75(%rip),%rsi
lea    0xe8d(%rip),%rdx
call   1050 <sprintf@plt>
jmp    11b6 <display_variable_aux_data+0x86>
lea    0x2ead(%rip),%rdi
lea    0xe56(%rip),%rsi
lea    0xe78(%rip),%rdx
call   1050 <sprintf@plt>
jmp    11bb <display_variable_aux_data+0x8b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
cmp    %ecx,%eax
jge    123e <display_variable_aux_data+0x10e>
lea    0x2e74(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    0x2e65(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
lea    0x2e57(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
movslq %eax,%rcx
mov    $0x78,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
lea    0xe0c(%rip),%rdx
movzbl (%rax,%rcx,1),%ecx
call   1040 <snprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c2 <display_variable_aux_data+0x92>
lea    0x2e0b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_variable_aux_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
mov    0x2(%rdi),%al
cmp    $0x7a,%al
lea    0xed7(%rip),%rcx
lea    0xeda(%rip),%rsi
cmove  %rcx,%rsi
cmp    $0x7f,%al
lea    0xebb(%rip),%rdx
cmovne %rsi,%rdx
lea    0x2ee9(%rip),%r14
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
call   1050 <sprintf@plt>
cmpb   $0x0,0x3(%r12)
je     11cd <display_variable_aux_data+0x9d>
xor    %ebx,%ebx
lea    0xeac(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%r13
add    %r14,%r13
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x77,%esi
sub    %eax,%esi
movzbl 0x4(%r12,%rbx,1),%ecx
mov    %r13,%rdi
mov    %r15,%rdx
call   1040 <snprintf@plt>
add    $0x1,%rbx
movzbl 0x3(%r12),%eax
cmp    %rax,%rbx
jb     1190 <display_variable_aux_data+0x60>
lea    0x2e7c(%rip),%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@display_variable_aux_data.outbuf = internal global [120 x i8] zeroinitializer
@.str = [23 x i8] c"func %12s : Data (hex)\00"
@.str.1 = [8 x i8] c"RFnoise\00"
@.str.2 = [10 x i8] c"RFrawdata\00"
@.str.3 = [10 x i8] c"RFunknown\00"
@.str.4 = [6 x i8] c" %02x\00"
define i8* @display_variable_aux_data(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 2
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 127
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @sprintf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %22
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 122
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @sprintf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %11
%20 = call i32 @sprintf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %21, %9
store i32 0, i32* %3
br label %23
23: ; preds = %46, %22
%24 = load i32, i32* %3
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp slt i32 %24, %28
br i1 %29, label %30, label %49
30: ; preds = %23
%31 = call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0))
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0), i64 %32
%34 = call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0))
%35 = sext i32 %34 to i64
%36 = sub i64 120, %35
%37 = sub i64 %36, 1
%38 = trunc i64 %37 to i32
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @snprintf(i8* %33, i32 %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %44)
br label %46
46: ; preds = %30
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %23
49: ; preds = %23
ret i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0)
}

LLVM IR (-O2):
@display_variable_aux_data.outbuf = internal global [120 x i8] zeroinitializer
@.str = [23 x i8] c"func %12s : Data (hex)\00"
@.str.1 = [8 x i8] c"RFnoise\00"
@.str.2 = [10 x i8] c"RFrawdata\00"
@.str.3 = [10 x i8] c"RFunknown\00"
@.str.4 = [6 x i8] c" %02x\00"
define i8* @display_variable_aux_data(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 2
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 122
%5 = select i1 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%6 = icmp eq i8 %3, 127
%7 = select i1 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %5
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %1, %12
%13 = phi i64 [ %23, %12 ], [ 0, %1 ]
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 %15
%17 = tail call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0))
%18 = sub i32 119, %17
%19 = add nuw nsw i64 %13, 4
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = tail call i32 @snprintf(i8* %16, i32 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %21)
%23 = add nuw nsw i64 %13, 1
%24 = load i8, i8* %9
%25 = zext i8 %24 to i64
%26 = icmp ult i64 %23, %25
br i1 %26, label %12, label %27
27: ; preds = %12, %1
ret i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_variable_aux_data.outbuf, i64 0, i64 0)
}