#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 *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int header(char *qs) {
  printf("Content-type: text/html\n\n");
  printf("<html>\n<head><title>WebSH</title></head>\n");
  printf("<body bgcolor=\"#ffffff\">\n");
  printf("<dir><h1>WebSH v1.0</h1>\n");
  printf("<ISINDEX prompt=\"Command to Execute: \">\n");
  printf("<br><b>Command output:</b> [<em>%s</em>]", qs);
  printf(" - %s\n", getenv("REMOTE_ADDR"));
  printf("<br><pre>\n");
}


x86 assembly (clang, -O0):
<header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf46(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xf30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<header>:
push   %rbx
mov    %rdi,%rbx
lea    0xf01(%rip),%rdi
call   1040 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1040 <puts@plt>
lea    0xf38(%rip),%rdi
call   1040 <puts@plt>
lea    0xf45(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe95(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf33(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Content-type: text/html\0A\0A\00"
@.str.1 = [42 x i8] c"<html>\0A<head><title>WebSH</title></head>\0A\00"
@.str.2 = [26 x i8] c"<body bgcolor=\22#ffffff\22>\0A\00"
@.str.3 = [26 x i8] c"<dir><h1>WebSH v1.0</h1>\0A\00"
@.str.4 = [41 x i8] c"<ISINDEX prompt=\22Command to Execute: \22>\0A\00"
@.str.5 = [41 x i8] c"<br><b>Command output:</b> [<em>%s</em>]\00"
@.str.6 = [7 x i8] c" - %s\0A\00"
@.str.7 = [12 x i8] c"REMOTE_ADDR\00"
@.str.8 = [11 x i8] c"<br><pre>\0A\00"
define i32 @header(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%11 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
@.str.5 = [41 x i8] c"<br><b>Command output:</b> [<em>%s</em>]\00"
@.str.6 = [7 x i8] c" - %s\0A\00"
@.str.7 = [12 x i8] c"REMOTE_ADDR\00"
@str = [25 x i8] c"Content-type: text/html\0A\00"
@str.9 = [41 x i8] c"<html>\0A<head><title>WebSH</title></head>\00"
@str.10 = [25 x i8] c"<body bgcolor=\22#ffffff\22>\00"
@str.11 = [25 x i8] c"<dir><h1>WebSH v1.0</h1>\00"
@str.12 = [40 x i8] c"<ISINDEX prompt=\22Command to Execute: \22>\00"
@str.13 = [10 x i8] c"<br><pre>\00"
define i32 @header(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%8 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.13, i64 0, i64 0))
ret i32 undef
}