#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;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
char A_REVERSE;
int PATH_MAX;
int /*<<< orphan*/ vsnprintf(char *, int, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, char);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
void curses_debug(void *ui, const char *fmt, va_list va) {
  WINDOW *win = ui;
  int i;
  char buff[PATH_MAX];
  vsnprintf(buff, sizeof(buff), fmt, va);
  wmove(win, 10, 0);
  for (i = 0; buff[i] != 0; i++) {
    waddch(win, A_REVERSE | buff[i]);
  }
}


x86 assembly (clang, -O0):
<curses_debug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <vsnprintf@plt>
mov    -0x20(%rbp),%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1050 <wmove@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11e3 <curses_debug+0xb3>
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%rdi
mov    0x2e18(%rip),%rax
movsbl (%rax),%eax
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
or     %ecx,%eax
movsbl %al,%esi
call   1030 <waddch@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119c <curses_debug+0x6c>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curses_debug>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %rdi,%r14
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r15
mov    %rsi,%r12
add    $0xf,%r12
and    $0xfffffffffffffff0,%r12
mov    %r15,%rbx
sub    %r12,%rbx
mov    %rbx,%rsp
neg    %r12
mov    %rbx,%rdi
call   1040 <vsnprintf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1050 <wmove@plt>
mov    (%r15,%r12,1),%al
test   %al,%al
je     11a9 <curses_debug+0x79>
add    $0x1,%rbx
mov    0x2e48(%rip),%r15
or     (%r15),%al
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <waddch@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <curses_debug+0x60>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@A_REVERSE = global i8 0
define void @curses_debug(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %7
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i8, i64 %14
store i64 %14, i64* %10
%17 = trunc i64 %14 to i32
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = call i32 @vsnprintf(i8* %16, i32 %17, i8* %18, i32 %19)
%21 = load i32*, i32** %7
%22 = call i32 @wmove(i32* %21, i32 10, i32 0)
store i32 0, i32* %8
br label %23
23: ; preds = %42, %3
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %16, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %45
30: ; preds = %23
%31 = load i32*, i32** %7
%32 = load i8, i8* @A_REVERSE
%33 = sext i8 %32 to i32
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %16, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = or i32 %33, %38
%40 = trunc i32 %39 to i8
%41 = call i32 @waddch(i32* %31, i8 signext %40)
br label %42
42: ; preds = %30
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %23
45: ; preds = %23
%46 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@A_REVERSE = global i8 0
define void @curses_debug(i8* %0, i8* nocapture %1, i32 %2) {
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32 @vsnprintf(i8* %7, i32 %5, i8* %1, i32 %2)
%9 = tail call i32 @wmove(i32* %4, i32 10, i32 0)
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %3, %12
%13 = phi i64 [ %18, %12 ], [ 0, %3 ]
%14 = phi i8 [ %20, %12 ], [ %10, %3 ]
%15 = load i8, i8* @A_REVERSE
%16 = or i8 %15, %14
%17 = tail call i32 @waddch(i32* %4, i8 signext %16)
%18 = add nuw i64 %13, 1
%19 = getelementptr inbounds i8, i8* %7, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %12, %3
ret void
}