#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 */
int /*<<< orphan*/ cgi_end();
int /*<<< orphan*/ cgi_init();
int /*<<< orphan*/ cgi_init_headers();
char *cgi_param(char *);
int /*<<< orphan*/ cgi_process_form();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int main(void) {
  cgi_init();
  cgi_process_form();
  cgi_init_headers();
  puts(""
       "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>"
       "<html>"
       "<head>"
       "	"
       " <meta http-equiv='content-type' content='text/html; "
       "charset=ISO-8859-1'>"
       "	"
       "   <meta name='author' content='Rafael Steil'>"
       "    <title>LIBCGI Examples</title>"
       "   </head>"
       "  <body text='#000000' bgcolor='#ffffff' link='#0000ee' "
       "vlink='#551a8b' alink='#0000ee'>"
       "");
  if (cgi_param("name"))
    printf("Name: %s<br>", cgi_param("name"));
  else
    puts("Name: Empty<br>");
  if (cgi_param("age"))
    printf("Age: %s<br>", cgi_param("age"));
  else
    puts("Age: Emtpy<br>");
  printf("Gender: %s<br>", cgi_param("gender"));
  printf("Radio Button 1: %s<br>", cgi_param("radiobutton1"));
  printf("Radio button 2: %s<br>", cgi_param("radiobutton2"));
  puts(""
       "</body>"
       "</html>"
       "");
  cgi_end();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <cgi_init@plt>
mov    $0x0,%al
call   1070 <cgi_process_form@plt>
mov    $0x0,%al
call   1050 <cgi_init_headers@plt>
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
lea    0xfa2(%rip),%rdi
call   1030 <cgi_param@plt>
cmp    $0x0,%rax
je     11d6 <main+0x66>
lea    0xf8c(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rsi
lea    0xf82(%rip),%rdi
call   1060 <printf@plt>
jmp    11e2 <main+0x72>
lea    0xf7e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf82(%rip),%rdi
call   1030 <cgi_param@plt>
cmp    $0x0,%rax
je     1218 <main+0xa8>
lea    0xf6c(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rsi
lea    0xf61(%rip),%rdi
call   1060 <printf@plt>
jmp    1224 <main+0xb4>
lea    0xf5c(%rip),%rdi
call   1040 <puts@plt>
lea    0xf6e(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rsi
lea    0xf50(%rip),%rdi
call   1060 <printf@plt>
lea    0xf71(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rsi
lea    0xf4b(%rip),%rdi
call   1060 <printf@plt>
lea    0xf7a(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rsi
lea    0xf54(%rip),%rdi
call   1060 <printf@plt>
lea    0xf6c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1090 <cgi_end@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1080 <cgi_init@plt>
xor    %eax,%eax
call   1070 <cgi_process_form@plt>
xor    %eax,%eax
call   1050 <cgi_init_headers@plt>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
lea    0xfb0(%rip),%rdi
call   1030 <cgi_param@plt>
test   %rax,%rax
je     11c0 <main+0x50>
lea    0xf9f(%rip),%rdi
call   1030 <cgi_param@plt>
lea    0xf98(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
jmp    11cc <main+0x5c>
lea    0xf94(%rip),%rdi
call   1040 <puts@plt>
lea    0xf98(%rip),%rdi
call   1030 <cgi_param@plt>
test   %rax,%rax
je     11fa <main+0x8a>
lea    0xf87(%rip),%rdi
call   1030 <cgi_param@plt>
lea    0xf7f(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
jmp    1206 <main+0x96>
lea    0xf7a(%rip),%rdi
call   1040 <puts@plt>
lea    0xf8c(%rip),%rdi
call   1030 <cgi_param@plt>
lea    0xf71(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xf8f(%rip),%rdi
call   1030 <cgi_param@plt>
lea    0xf6c(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xf98(%rip),%rdi
call   1030 <cgi_param@plt>
lea    0xf75(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xf8a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <cgi_end@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [329 x i8] c"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head>\09 <meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>\09 <meta name='author' content='Rafael Steil'> <title>LIBCGI Examples</title> </head> <body text='' bgcolor='#ffffff' link='ee' vlink='a8b' alink='ee'>\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [13 x i8] c"Name: %s<br>\00"
@.str.3 = [16 x i8] c"Name: Empty<br>\00"
@.str.4 = [4 x i8] c"age\00"
@.str.5 = [12 x i8] c"Age: %s<br>\00"
@.str.6 = [15 x i8] c"Age: Emtpy<br>\00"
@.str.7 = [15 x i8] c"Gender: %s<br>\00"
@.str.8 = [7 x i8] c"gender\00"
@.str.9 = [23 x i8] c"Radio Button 1: %s<br>\00"
@.str.10 = [13 x i8] c"radiobutton1\00"
@.str.11 = [23 x i8] c"Radio button 2: %s<br>\00"
@.str.12 = [13 x i8] c"radiobutton2\00"
@.str.13 = [15 x i8] c"</body></html>\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @cgi_init()
%3 = call i32 (...) @cgi_process_form()
%4 = call i32 (...) @cgi_init_headers()
%5 = call i32 @puts(i8* getelementptr inbounds ([329 x i8], [329 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @cgi_param(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i8* @cgi_param(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = call i8* @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i8* @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %21
19: ; preds = %13
%20 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = call i8* @cgi_param(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %22)
%24 = call i8* @cgi_param(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %24)
%26 = call i8* @cgi_param(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %26)
%28 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%29 = call i32 (...) @cgi_end()
ret i32 0
}

LLVM IR (-O2):
@.str = [329 x i8] c"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head>\09 <meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>\09 <meta name='author' content='Rafael Steil'> <title>LIBCGI Examples</title> </head> <body text='' bgcolor='#ffffff' link='ee' vlink='a8b' alink='ee'>\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [13 x i8] c"Name: %s<br>\00"
@.str.3 = [16 x i8] c"Name: Empty<br>\00"
@.str.4 = [4 x i8] c"age\00"
@.str.5 = [12 x i8] c"Age: %s<br>\00"
@.str.6 = [15 x i8] c"Age: Emtpy<br>\00"
@.str.7 = [15 x i8] c"Gender: %s<br>\00"
@.str.8 = [7 x i8] c"gender\00"
@.str.9 = [23 x i8] c"Radio Button 1: %s<br>\00"
@.str.10 = [13 x i8] c"radiobutton1\00"
@.str.11 = [23 x i8] c"Radio button 2: %s<br>\00"
@.str.12 = [13 x i8] c"radiobutton2\00"
@.str.13 = [15 x i8] c"</body></html>\00"
define i32 @main() {
%1 = tail call i32 (...) @cgi_init()
%2 = tail call i32 (...) @cgi_process_form()
%3 = tail call i32 (...) @cgi_init_headers()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([329 x i8], [329 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @cgi_param(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = tail call i8* @cgi_param(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = tail call i8* @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i8* @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %16)
br label %20
18: ; preds = %12
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = tail call i8* @cgi_param(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%22 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %21)
%23 = tail call i8* @cgi_param(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%24 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%25 = tail call i8* @cgi_param(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%26 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %25)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%28 = tail call i32 (...) @cgi_end()
ret i32 0
}