#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*/ environ_name_to_value(char *, char *);
int /*<<< orphan*/ piece(char *, char, char *, int /*<<< orphan*/);
char *environ_get_http_referer(void) {
  char http_referer_with_parameter[512];
  static char http_referer[512];
  if (!environ_name_to_value(http_referer_with_parameter, "HTTP_REFERER")) {
    return (char *)0;
  } else {
    piece(http_referer, '?', http_referer_with_parameter, 0);
    return http_referer;
  }
}


x86 assembly (clang, -O0):
<environ_get_http_referer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    -0x210(%rbp),%rdi
lea    0xec7(%rip),%rsi
call   1030 <environ_name_to_value@plt>
cmp    $0x0,%eax
jne    1154 <environ_get_http_referer+0x34>
movq   $0x0,-0x8(%rbp)
jmp    1179 <environ_get_http_referer+0x59>
lea    -0x210(%rbp),%rdx
lea    0x2ede(%rip),%rdi
mov    $0x3f,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
lea    0x2ecb(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<environ_get_http_referer>:
push   %rbx
sub    $0x200,%rsp
lea    0xed1(%rip),%rsi
mov    %rsp,%rdi
call   1030 <environ_name_to_value@plt>
test   %eax,%eax
je     1156 <environ_get_http_referer+0x36>
lea    0x2efe(%rip),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x3f,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
jmp    1158 <environ_get_http_referer+0x38>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@environ_get_http_referer.http_referer = internal global [512 x i8] zeroinitializer
@.str = [13 x i8] c"HTTP_REFERER\00"
define i8* @environ_get_http_referer() {
%1 = alloca i8*
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = call i32 @environ_name_to_value(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i8* null, i8** %1
br label %10
7: ; preds = %0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = call i32 @piece(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @environ_get_http_referer.http_referer, i64 0, i64 0), i8 signext 63, i8* %8, i32 0)
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @environ_get_http_referer.http_referer, i64 0, i64 0), i8** %1
br label %10
10: ; preds = %7, %6
%11 = load i8*, i8** %1
ret i8* %11
}

LLVM IR (-O2):
@environ_get_http_referer.http_referer = internal global [512 x i8] zeroinitializer
@.str = [13 x i8] c"HTTP_REFERER\00"
define i8* @environ_get_http_referer() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = call i32 @environ_name_to_value(i8* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @piece(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @environ_get_http_referer.http_referer, i64 0, i64 0), i8 signext 63, i8* %2, i32 0)
br label %7
7: ; preds = %0, %5
%8 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @environ_get_http_referer.http_referer, i64 0, i64 0), %5 ], [ null, %0 ]
ret i8* %8
}