#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*/ ReportChar(int, char);
int /*<<< orphan*/ ReportString(int, char *, ...);
__attribute__((visibility("hidden"))) void
ReportBufferCtrl(int level, const unsigned char *buffer, unsigned int length) {
  ReportChar(level, '[');
  ReportString(level, "(%d) ", length);
  while (length--) {
    ReportString(level, "%02x ", (unsigned char)*buffer);
    buffer++;
  }
  ReportString(level, "]\n");
}


x86 assembly (clang, -O0):
<ReportBufferCtrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x5b,%esi
call   1030 <ReportChar@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1040 <ReportString@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1190 <ReportBufferCtrl+0x70>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movzbl (%rax),%edx
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1040 <ReportString@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <ReportBufferCtrl+0x33>
mov    -0x4(%rbp),%edi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <ReportString@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReportBufferCtrl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %edi,%r12d
mov    $0x5b,%esi
call   1030 <ReportChar@plt>
lea    0xebf(%rip),%rsi
mov    %r12d,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <ReportString@plt>
test   %ebp,%ebp
je     117a <ReportBufferCtrl+0x5a>
mov    %ebp,%ebp
lea    0xeac(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%edx
mov    %r12d,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <ReportString@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1160 <ReportBufferCtrl+0x40>
lea    0xe8b(%rip),%rsi
mov    %r12d,%edi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ReportString@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"(%d) \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [3 x i8] c"]\0A\00"
define hidden void @ReportBufferCtrl(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = call i32 @ReportChar(i32 %7, i8 signext 91)
%9 = load i32, i32* %4
%10 = load i32, i32* %6
%11 = call i32 (i32, i8*, ...) @ReportString(i32 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %16, %3
%13 = load i32, i32* %6
%14 = add i32 %13, -1
store i32 %14, i32* %6
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %4
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i32, i8*, ...) @ReportString(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %12
24: ; preds = %12
%25 = load i32, i32* %4
%26 = call i32 (i32, i8*, ...) @ReportString(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"(%d) \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [3 x i8] c"]\0A\00"
define hidden void @ReportBufferCtrl(i32 %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @ReportChar(i32 %0, i8 signext 91)
%5 = tail call i32 (i32, i8*, ...) @ReportString(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %2)
%6 = icmp eq i32 %2, 0
br i1 %6, label %16, label %7
7: ; preds = %3, %7
%8 = phi i32 [ %10, %7 ], [ %2, %3 ]
%9 = phi i8* [ %14, %7 ], [ %1, %3 ]
%10 = add i32 %8, -1
%11 = load i8, i8* %9
%12 = zext i8 %11 to i32
%13 = tail call i32 (i32, i8*, ...) @ReportString(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = icmp eq i32 %10, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %3
%17 = tail call i32 (i32, i8*, ...) @ReportString(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}