#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 */
char *dpsnaffle(char const *, char const *, int, int *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ pdperror(char const *);
int /*<<< orphan*/ printobj(char *, int);
int /*<<< orphan*/ printobjhex(char *, int);
int /*<<< orphan*/ putchar(char);
int dosnaffle(const char *name, const char *kbuf, int ksiz, int ox, int nb) {
  char *vbuf;
  int vsiz;
  if (!(vbuf = dpsnaffle(name, kbuf, ksiz, &vsiz))) {
    pdperror(name);
    return 1;
  }
  if (ox) {
    printobjhex(vbuf, vsiz);
  } else {
    printobj(vbuf, vsiz);
  }
  free(vbuf);
  if (!nb)
    putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<dosnaffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x34(%rbp),%rcx
call   1080 <dpsnaffle@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11b1 <dosnaffle+0x51>
mov    -0x10(%rbp),%rdi
call   1060 <pdperror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fc <dosnaffle+0x9c>
cmpl   $0x0,-0x20(%rbp)
je     11cc <dosnaffle+0x6c>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <printobjhex@plt>
jmp    11d8 <dosnaffle+0x78>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <printobj@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x24(%rbp)
jne    11f5 <dosnaffle+0x95>
mov    $0xa,%edi
call   1040 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dosnaffle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdi,%rbp
lea    0x4(%rsp),%rcx
call   1080 <dpsnaffle@plt>
test   %rax,%rax
je     1195 <dosnaffle+0x35>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
mov    %rax,%rdi
test   %r15d,%r15d
je     11a4 <dosnaffle+0x44>
call   1070 <printobjhex@plt>
jmp    11a9 <dosnaffle+0x49>
mov    %rbp,%rdi
call   1060 <pdperror@plt>
mov    $0x1,%ebx
jmp    11c2 <dosnaffle+0x62>
call   1050 <printobj@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
test   %r14d,%r14d
jne    11c2 <dosnaffle+0x62>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dosnaffle(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i32, i32* %9
%17 = call i8* @dpsnaffle(i8* %14, i8* %15, i32 %16, i32* %13)
store i8* %17, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %5
%20 = load i8*, i8** %7
%21 = call i32 @pdperror(i8* %20)
store i32 1, i32* %6
br label %41
22: ; preds = %5
%23 = load i32, i32* %10
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8*, i8** %12
%27 = load i32, i32* %13
%28 = call i32 @printobjhex(i8* %26, i32 %27)
br label %33
29: ; preds = %22
%30 = load i8*, i8** %12
%31 = load i32, i32* %13
%32 = call i32 @printobj(i8* %30, i32 %31)
br label %33
33: ; preds = %29, %25
%34 = load i8*, i8** %12
%35 = call i32 @free(i8* %34)
%36 = load i32, i32* %11
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %33
%39 = call i32 @putchar(i8 signext 10)
br label %40
40: ; preds = %38, %33
store i32 0, i32* %6
br label %41
41: ; preds = %40, %19
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
define i32 @dosnaffle(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = call i8* @dpsnaffle(i8* %0, i8* %1, i32 %2, i32* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @pdperror(i8* %0)
br label %24
12: ; preds = %5
%13 = icmp eq i32 %3, 0
%14 = load i32, i32* %6
br i1 %13, label %17, label %15
15: ; preds = %12
%16 = call i32 @printobjhex(i8* %8, i32 %14)
br label %19
17: ; preds = %12
%18 = call i32 @printobj(i8* %8, i32 %14)
br label %19
19: ; preds = %17, %15
%20 = call i32 @free(i8* %8)
%21 = icmp eq i32 %4, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @putchar(i8 signext 10)
br label %24
24: ; preds = %19, %22, %10
%25 = phi i32 [ 1, %10 ], [ 0, %22 ], [ 0, %19 ]
ret i32 %25
}