#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*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *display_binbuffer(unsigned char *buff) {
  int j;
  static char outbuff[120];
  strcpy(outbuff, "Buffer =");
  for (j = 0; j < buff[0]; j++) {
    sprintf(outbuff + strlen(outbuff), " %02x", buff[1 + j]);
  }
  return outbuff;
}


x86 assembly (clang, -O0):
<display_binbuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jge    11ab <display_binbuffer+0x7b>
lea    0x2ee1(%rip),%rdi
call   1040 <strlen@plt>
cltq
lea    0x2ed3(%rip),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
lea    0xe75(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1050 <sprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <display_binbuffer+0x26>
lea    0x2e9e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_binbuffer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0x2f0e(%rip),%r14
lea    0xeb7(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,(%r12)
je     119a <display_binbuffer+0x6a>
xor    %ebx,%ebx
lea    0xea8(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
movzbl 0x1(%r12,%rbx,1),%edx
add    $0x1,%rbx
mov    %r15,%rsi
call   1050 <sprintf@plt>
movzbl (%r12),%eax
cmp    %rax,%rbx
jb     1170 <display_binbuffer+0x40>
lea    0x2eaf(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@display_binbuffer.outbuff = internal global [120 x i8] zeroinitializer
@.str = [9 x i8] c"Buffer =\00"
@.str.1 = [6 x i8] c" %02x\00"
define i8* @display_binbuffer(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @strcpy(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %3
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = icmp slt i32 %6, %10
br i1 %11, label %12, label %26
12: ; preds = %5
%13 = call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0))
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0), i64 %14
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = add nsw i32 1, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %21)
br label %23
23: ; preds = %12
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %5
26: ; preds = %5
ret i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0)
}

LLVM IR (-O2):
@display_binbuffer.outbuff = internal global [120 x i8] zeroinitializer
@.str = [9 x i8] c"Buffer =\00"
@.str.1 = [6 x i8] c" %02x\00"
define i8* @display_binbuffer(i8* nocapture %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %10, %5 ], [ 0, %1 ]
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 %8
%10 = add nuw nsw i64 %6, 1
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %12)
%14 = load i8, i8* %0
%15 = zext i8 %14 to i64
%16 = icmp ult i64 %10, %15
br i1 %16, label %5, label %17
17: ; preds = %5, %1
ret i8* getelementptr inbounds ([120 x i8], [120 x i8]* @display_binbuffer.outbuff, i64 0, i64 0)
}