#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*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ stdout;
int main(void) {
  char *ip_str = NULL;
  if ((ip_str = getenv("REMOTE_ADDR")) != NULL)
    fprintf(stdout,
            "Pragma: no-cache\r\n"
            "Content-Type: text/plain\r\n\r\n%s\r\n",
            ip_str);
  else
    fprintf(stdout, "Pragma: no-cache\r\n"
                    "Content-Type: text/plain\r\n\r\nNULL\r\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xec2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1171 <main+0x51>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1188 <main+0x68>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
mov    0x2eac(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
je     114e <main+0x2e>
lea    0xeca(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    115c <main+0x3c>
lea    0xeea(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"REMOTE_ADDR\00"
@stdout = global i32 0
@.str.1 = [51 x i8] c"Pragma: no-cache\0D\0AContent-Type: text/plain\0D\0A\0D\0A%s\0D\0A\00"
@.str.2 = [53 x i8] c"Pragma: no-cache\0D\0AContent-Type: text/plain\0D\0A\0D\0ANULL\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
%3 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @stdout
%7 = load i8*, i8** %2
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %12
9: ; preds = %0
%10 = load i32, i32* @stdout
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %9, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"REMOTE_ADDR\00"
@stdout = global i32 0
@.str.1 = [51 x i8] c"Pragma: no-cache\0D\0AContent-Type: text/plain\0D\0A\0D\0A%s\0D\0A\00"
@.str.2 = [53 x i8] c"Pragma: no-cache\0D\0AContent-Type: text/plain\0D\0A\0D\0ANULL\0D\0A\00"
define i32 @main() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
%3 = load i32, i32* @stdout
br i1 %2, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %8
6: ; preds = %0
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
ret i32 0
}