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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void dump_maddr(FILE *pigsty, const char *field, const unsigned char *buffer,
                const size_t buffer_size) {
  const unsigned char *bp = NULL;
  const unsigned char *bp_end = NULL;
  if (pigsty == NULL || field == NULL || buffer == NULL || buffer_size == 0) {
    return;
  }
  bp = buffer;
  bp_end = bp + buffer_size;
  fprintf(pigsty,
          "\n "
          "%s = \"",
          field);
  while (bp != bp_end) {
    fprintf(pigsty, "%.2X", *bp);
    bp++;
    if (bp != bp_end) {
      fprintf(pigsty, ":");
    }
  }
  fprintf(pigsty, "\"");
}


x86 assembly (clang, -O0):
<dump_maddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1164 <dump_maddr+0x54>
cmpq   $0x0,-0x10(%rbp)
je     1164 <dump_maddr+0x54>
cmpq   $0x0,-0x18(%rbp)
je     1164 <dump_maddr+0x54>
cmpq   $0x0,-0x20(%rbp)
jne    1169 <dump_maddr+0x59>
jmp    11fd <dump_maddr+0xed>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     11eb <dump_maddr+0xdb>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
movzbl (%rax),%edx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     11e6 <dump_maddr+0xd6>
mov    -0x8(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1193 <dump_maddr+0x83>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_maddr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
je     11ce <dump_maddr+0xae>
mov    %rdx,%r15
mov    %rsi,%rdx
test   %rsi,%rsi
je     11ce <dump_maddr+0xae>
test   %r15,%r15
je     11ce <dump_maddr+0xae>
mov    %rcx,%r14
test   %rcx,%rcx
je     11ce <dump_maddr+0xae>
mov    %rdi,%r13
lea    0xea0(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
movzbl (%r15),%edx
lea    0xe97(%rip),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1,%r14
je     11b8 <dump_maddr+0x98>
mov    $0x1,%ebx
lea    0xe7b(%rip),%r12
xchg   %ax,%ax
mov    $0x3a,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
movzbl (%r15,%rbx,1),%edx
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <dump_maddr+0x70>
mov    $0x22,%edi
mov    %r13,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"\0A %s = \22\00"
@.str.1 = [5 x i8] c"%.2X\00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [2 x i8] c"\22\00"
define void @dump_maddr(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i8* null, i8** %9
store i8* null, i8** %10
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %22, label %13
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i64, i64* %8
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19, %16, %13, %4
br label %53
23: ; preds = %19
%24 = load i8*, i8** %7
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = load i64, i64* %8
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8* %27, i8** %10
%28 = load i32*, i32** %5
%29 = load i8*, i8** %6
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %49, %23
%32 = load i8*, i8** %9
%33 = load i8*, i8** %10
%34 = icmp ne i8* %32, %33
br i1 %34, label %35, label %50
35: ; preds = %31
%36 = load i32*, i32** %5
%37 = load i8*, i8** %9
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i8*, i8** %9
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %9
%43 = load i8*, i8** %9
%44 = load i8*, i8** %10
%45 = icmp ne i8* %43, %44
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = load i32*, i32** %5
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %46, %35
br label %31
50: ; preds = %31
%51 = load i32*, i32** %5
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %50, %22
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"\0A %s = \22\00"
@.str.1 = [5 x i8] c"%.2X\00"
define void @dump_maddr(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = icmp eq i32* %0, null
%6 = icmp eq i8* %1, null
%7 = or i1 %5, %6
%8 = icmp eq i8* %2, null
%9 = or i1 %7, %8
%10 = icmp eq i64 %3, 0
%11 = or i1 %9, %10
br i1 %11, label %31, label %12
12: ; preds = %4
%13 = getelementptr inbounds i8, i8* %2, i64 %3
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1)
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %3, 1
br i1 %18, label %29, label %19
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %2, i64 1
br label %21
21: ; preds = %19, %21
%22 = phi i8* [ %20, %19 ], [ %27, %21 ]
%23 = tail call i32 @fputc(i32 58, i32* %0)
%24 = load i8, i8* %22
%25 = zext i8 %24 to i32
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds i8, i8* %22, i64 1
%28 = icmp eq i8* %27, %13
br i1 %28, label %29, label %21
29: ; preds = %21, %12
%30 = tail call i32 @fputc(i32 34, i32* %0)
br label %31
31: ; preds = %4, %29
ret void
}