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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ isprint(char);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ vsnprintf(char *, int, char const *, int /*<<< orphan*/);
void auth_debug(const char *fmt, va_list ap) {
  char buf[(1 << 10)];
  int i;
  int len;
  vsnprintf(buf, (1 << 10), fmt, ap);
  len = strlen(buf);
  for (i = 0; i < len; i++)
    if (!isprint(buf[i]))
      buf[i] = '.';
  fprintf(stderr, buf);
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<auth_debug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    $0x400,%esi
call   1030 <vsnprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x418(%rbp)
movl   $0x0,-0x414(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x418(%rbp),%eax
jge    11dd <auth_debug+0x9d>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1060 <isprint@plt>
cmp    $0x0,%eax
jne    11c4 <auth_debug+0x84>
movslq -0x414(%rbp),%rax
movb   $0x2e,-0x410(%rbp,%rax,1)
2e
jmp    11c9 <auth_debug+0x89>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1186 <auth_debug+0x46>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
call   1050 <fprintf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_debug>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %esi,%ecx
mov    %rdi,%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1030 <vsnprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    119c <auth_debug+0x5c>
mov    %eax,%r14d
xor    %ebx,%ebx
jmp    1189 <auth_debug+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     119c <auth_debug+0x5c>
movsbl (%rsp,%rbx,1),%edi
call   1060 <isprint@plt>
test   %eax,%eax
jne    1180 <auth_debug+0x40>
movb   $0x2e,(%rsp,%rbx,1)
jmp    1180 <auth_debug+0x40>
mov    0x2e3d(%rip),%rbx
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe4a(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @auth_debug(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @vsnprintf(i8* %8, i32 1024, i8* %9, i32 %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
store i32 0, i32* %6
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @isprint(i8 signext %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %27
store i8 46, i8* %28
br label %29
29: ; preds = %25, %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %14
33: ; preds = %14
%34 = load i32, i32* @stderr
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = call i32 @fprintf(i32 %34, i8* %35)
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @auth_debug(i8* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @vsnprintf(i8* %4, i32 1024, i8* %0, i32 %1)
%6 = call i32 @strlen(i8* %4)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %17
%11 = phi i64 [ 0, %8 ], [ %18, %17 ]
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @isprint(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i8 46, i8* %12
br label %17
17: ; preds = %10, %16
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %10
20: ; preds = %17, %2
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* %4)
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}