#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*/ send_str(int, char *);
void send_redirect(int socket, int redirect_code, char *location) {
  if (redirect_code == 301) {
    send_str(socket, "HTTP/1.0 301 Move Permanently\r\n");
    send_str(socket, "Location: ");
    send_str(socket, location);
    send_str(socket, "\r\n");
  }
  send_str(socket, "\r\n");
}


x86 assembly (clang, -O0):
<send_redirect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x12d,-0x8(%rbp)
jne    1168 <send_redirect+0x58>
mov    -0x4(%rbp),%edi
lea    0xec7(%rip),%rsi
call   1030 <send_str@plt>
mov    -0x4(%rbp),%edi
lea    0xed8(%rip),%rsi
call   1030 <send_str@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <send_str@plt>
mov    -0x4(%rbp),%edi
lea    0xeba(%rip),%rsi
call   1030 <send_str@plt>
mov    -0x4(%rbp),%edi
lea    0xeab(%rip),%rsi
call   1030 <send_str@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_redirect>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x12d,%esi
jne    1155 <send_redirect+0x45>
mov    %rdx,%r14
lea    0xed8(%rip),%rsi
mov    %ebx,%edi
call   1030 <send_str@plt>
lea    0xeea(%rip),%rsi
mov    %ebx,%edi
call   1030 <send_str@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <send_str@plt>
lea    0xecf(%rip),%rsi
mov    %ebx,%edi
call   1030 <send_str@plt>
lea    0xec1(%rip),%rsi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <send_str@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"HTTP/1.0 301 Move Permanently\0D\0A\00"
@.str.1 = [11 x i8] c"Location: \00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @send_redirect(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 301
br i1 %8, label %9, label %19
9: ; preds = %3
%10 = load i32, i32* %4
%11 = call i32 @send_str(i32 %10, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = call i32 @send_str(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %4
%15 = load i8*, i8** %6
%16 = call i32 @send_str(i32 %14, i8* %15)
%17 = load i32, i32* %4
%18 = call i32 @send_str(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %9, %3
%20 = load i32, i32* %4
%21 = call i32 @send_str(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"HTTP/1.0 301 Move Permanently\0D\0A\00"
@.str.1 = [11 x i8] c"Location: \00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @send_redirect(i32 %0, i32 %1, i8* %2) {
%4 = icmp eq i32 %1, 301
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = tail call i32 @send_str(i32 %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @send_str(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @send_str(i32 %0, i8* %2)
%9 = tail call i32 @send_str(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %5, %3
%11 = tail call i32 @send_str(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}