// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/lib/htmshell.c
// Function: htmlVaWarn
void htmlVaWarn(char *format, va_list args)
/* Write an error message. */
{
va_list argscp;
va_copy(argscp, args);
htmlWarnBoxSetup(stdout); // sets up the warnBox if it hasn't already been done.
char warning[1024];

// html-encode arguments to fight XSS
struct dyString *ds = newDyString(1024);
vaHtmlDyStringPrintf(ds, format, args);
int n = ds->stringSize;
int nLimit = sizeof(warning) - 1;
if (ds->stringSize > nLimit)
    n = nLimit;
safencpy(warning, sizeof warning, ds->string, n);
if (ds->stringSize > nLimit)
    strcpy(warning+n-5,"[...]"); // show truncation
freeDyString(&ds);

// Replace newlines with BR tag
char *warningBR = htmlWarnEncode(warning); 

// Javascript-encode the entire message because it is
// going to appear as a javascript string literal
// as it gets appended to the warnList html.
// JS-encoding here both allows us to use any character in the message
// and keeps js-encodings in events like onmouseover="stuff %s|js| stuff" secure.
char *jsEncodedMessage = javascriptEncode (warningBR); 
freeMem(warningBR);
struct dyString *dy = dyStringNew(2048);
dyStringPrintf(dy,
    "showWarnBox();"
    "var warnList=document.getElementById('warnList');"
    "warnList.innerHTML += '<li>%s</li>';\n", jsEncodedMessage);
jsInline(dy->string);  
// TODO GALT does --ERROR -- tag still work?
printf("<!-- ERROR -->\n");
// NOTE that "--ERROR --" is needed at the end of this print!!
dyStringFree(&dy);
freeMem(jsEncodedMessage);

/* Log useful CGI info to stderr */
logCgiToStderr();

/* write warning/error message to stderr so they get logged. */
vfprintf(stderr, format, argscp);
fprintf(stderr, "\n");
fflush(stderr);
va_end(argscp);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %rax
movq %rax, 0x20(%rsp)
movups (%rsi), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0xb7d7b(%rip), %rax     # 0xbefb0
movq (%rax), %rdi
callq 0x489bb
movl $0x400, %edi            # imm = 0x400
callq 0x264e0
movq %rax, %r15
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x47e6c
movl 0x14(%r15), %eax
movl $0x3ff, %ecx            # imm = 0x3FF
cmpl %ecx, %eax
cmovll %eax, %ecx
movq 0x8(%r15), %rdx
movslq %ecx, %r14
leaq 0x30(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rcx
callq 0x23fb3
cmpl $0x400, 0x14(%r15)      # imm = 0x400
jl 0x729f
movw $0x5d, 0x2f(%rsp,%r14)
movl $0x2e2e2e5b, 0x2b(%rsp,%r14) # imm = 0x2E2E2E5B
leaq 0x8(%rsp), %rdi
callq 0x2651d
leaq 0x30(%rsp), %rdi
callq 0x4833d
movq %rax, %r15
movq %rax, %rdi
callq 0x488a7
movq %rax, %r14
movq %r15, %rdi
callq 0x2e0a0
movl $0x800, %edi            # imm = 0x800
callq 0x264e0
movq %rax, %r15
leaq 0x28(%rsp), %r12
movq %rax, (%r12)
leaq 0x8fc07(%rip), %rsi     # 0x96eed
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x26883
movq 0x8(%r15), %rdi
callq 0x4400e
leaq 0x905a7(%rip), %rdi     # 0x978aa
callq 0x6bb0
movq %r12, %rdi
callq 0x2651d
movq %r14, %rdi
callq 0x2e0a0
xorl %eax, %eax
callq 0x703d
movq 0xb7cb2(%rip), %r14     # 0xbefd8
movq (%r14), %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rsi
callq 0x69e0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x6930
movq (%r14), %rdi
callq 0x6870
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r14
popq %r15
retq