#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();
scalar_t__ cgi_param(char *);
int /*<<< orphan*/ cgi_process_form();
int /*<<< orphan*/ cgi_redirect(scalar_t__);
int /*<<< orphan*/ example_description();
int /*<<< orphan*/ puts(char *);
int main() {
  cgi_init();
  cgi_process_form();
  if (cgi_param("url"))
    cgi_redirect(cgi_param("url"));
  cgi_init_headers();
  example_description();
  puts("<html>"
       "<head><title>Redirect example</title>"
       "</head>"
       "<body>"
       "<form action='redirect.cgi' method='GET'>"
       "URL to redirect: <input type=text name=url value='http://'><br>"
       "<input type=submit value='Click to redirect'>"
       "</form>"
       "</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   1090 <cgi_init@plt>
mov    $0x0,%al
call   1070 <cgi_process_form@plt>
lea    0xe5c(%rip),%rdi
call   1030 <cgi_param@plt>
cmp    $0x0,%rax
je     11c7 <main+0x47>
lea    0xe46(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rdi
call   1080 <cgi_redirect@plt>
mov    $0x0,%al
call   1060 <cgi_init_headers@plt>
mov    $0x0,%al
call   1050 <example_description@plt>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   10a0 <cgi_end@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1090 <cgi_init@plt>
xor    %eax,%eax
call   1070 <cgi_process_form@plt>
lea    0xe6a(%rip),%rdi
call   1030 <cgi_param@plt>
test   %rax,%rax
je     11b4 <main+0x34>
lea    0xe59(%rip),%rdi
call   1030 <cgi_param@plt>
mov    %rax,%rdi
call   1080 <cgi_redirect@plt>
xor    %eax,%eax
call   1060 <cgi_init_headers@plt>
xor    %eax,%eax
call   1050 <example_description@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10a0 <cgi_end@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"url\00"
@.str.1 = [227 x i8] c"<html><head><title>Redirect example</title></head><body><form action='redirect.cgi' method='GET'>URL to redirect: <input type=text name=url value='http://'><br><input type=submit value='Click to redirect'></form></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 i64 @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i64 @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @cgi_redirect(i64 %7)
br label %9
9: ; preds = %6, %0
%10 = call i32 (...) @cgi_init_headers()
%11 = call i32 (...) @example_description()
%12 = call i32 @puts(i8* getelementptr inbounds ([227 x i8], [227 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @cgi_end()
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"url\00"
@.str.1 = [227 x i8] c"<html><head><title>Redirect example</title></head><body><form action='redirect.cgi' method='GET'>URL to redirect: <input type=text name=url value='http://'><br><input type=submit value='Click to redirect'></form></body></html>\00"
define i32 @main() {
%1 = tail call i32 (...) @cgi_init()
%2 = tail call i32 (...) @cgi_process_form()
%3 = tail call i64 @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i64 @cgi_param(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @cgi_redirect(i64 %6)
br label %8
8: ; preds = %5, %0
%9 = tail call i32 (...) @cgi_init_headers()
%10 = tail call i32 (...) @example_description()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([227 x i8], [227 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 (...) @cgi_end()
ret i32 0
}