#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*/ printf(char *, ...);
int strlen(char const *);
void cgiRedirect(const char *url) {
  if (url && strlen(url)) {
    printf("Content-type: text/html\nContent-length: %d\n",
           77 + (strlen(url) * 2));
    printf("Status: 302 Temporal Relocation\n");
    printf("Location: %s\n\n", url);
    printf("<html>\n<body>\nThe page has been moved to <a "
           "href=\"%s\">%s</a>\n</body>\n</html>\n",
           url, url);
  }
}


x86 assembly (clang, -O0):
<cgiRedirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119e <cgiRedirect+0x7e>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     119e <cgiRedirect+0x7e>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
shl    $0x1,%esi
add    $0x4d,%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgiRedirect>:
push   %rbx
test   %rdi,%rdi
je     1190 <cgiRedirect+0x60>
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     1190 <cgiRedirect+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rax,1),%esi
add    $0x4d,%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Content-type: text/html\0AContent-length: %d\0A\00"
@.str.1 = [33 x i8] c"Status: 302 Temporal Relocation\0A\00"
@.str.2 = [15 x i8] c"Location: %s\0A\0A\00"
@.str.3 = [78 x i8] c"<html>\0A<body>\0AThe page has been moved to <a href=\22%s\22>%s</a>\0A</body>\0A</html>\0A\00"
define void @cgiRedirect(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %21
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = mul nsw i32 %11, 2
%13 = add nsw i32 77, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %2
%19 = load i8*, i8** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %18, i8* %19)
br label %21
21: ; preds = %9, %5, %1
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"Content-type: text/html\0AContent-length: %d\0A\00"
@.str.2 = [15 x i8] c"Location: %s\0A\0A\00"
@.str.3 = [78 x i8] c"<html>\0A<body>\0AThe page has been moved to <a href=\22%s\22>%s</a>\0A</body>\0A</html>\0A\00"
@str = [32 x i8] c"Status: 302 Temporal Relocation\00"
define void @cgiRedirect(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = shl nsw i32 %7, 1
%9 = add nsw i32 %8, 77
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %0)
br label %14
14: ; preds = %6, %3, %1
ret void
}