#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*/ sprintf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write_socket(int, char *, int);
void Unauthorized_response(int client_sockfd) {
  char buffer[8096];
  char body[8096];
  sprintf(buffer, "HTTP/1.1 401 Unauthorization\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "Server: httpServer/0.1.1\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(buffer, "WWW-Authenticate: Basic realm="
                  "\r\n");
  write_socket(client_sockfd, buffer, strlen(buffer));
  sprintf(body,
          "<HTML><HEAD><TITLE>Unauthorization Request</TITLE></HEAD>\r\n");
  sprintf(body + strlen(body),
          "<BODY><P>Client did't authorized by server,please check your usr "
          "and pwd.</P></BODY></HTML>\r\n");
  write_socket(client_sockfd, "\r\n", strlen("\r\n"));
  write_socket(client_sockfd, body, strlen(body));
}


x86 assembly (clang, -O0):
<Unauthorized_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3fa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x1fb0(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f94(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f90(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f94(%rbp),%edi
mov    -0x3f90(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f84(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f80(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f84(%rbp),%edi
mov    -0x3f80(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x1fb0(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f74(%rbp)
lea    -0x1fb0(%rbp),%rax
mov    %rax,-0x3f70(%rbp)
lea    -0x1fb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f74(%rbp),%edi
mov    -0x3f70(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
lea    -0x3f50(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f68(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f68(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xe3b(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f60(%rbp)
lea    0xdc6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x3f60(%rbp),%edi
mov    %eax,%edx
lea    0xdb2(%rip),%rsi
call   1030 <write_socket@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3f5c(%rbp)
lea    -0x3f50(%rbp),%rax
mov    %rax,-0x3f58(%rbp)
lea    -0x3f50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x3f5c(%rbp),%edi
mov    -0x3f58(%rbp),%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3fa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Unauthorized_response>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3f40,%rsp
mov    %edi,%ebp
movups 0xecc(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xecc(%rip),%xmm0
movups %xmm0,0x1faf(%rsp)
lea    0x1fa0(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xeb1(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xead(%rip),%xmm0
movups %xmm0,0x1fab(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe9a(%rip),%xmm0
movaps %xmm0,0x1fa0(%rsp)
movups 0xe9b(%rip),%xmm0
movaps %xmm0,0x1fb0(%rsp)
movb   $0x0,0x1fc0(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
movups 0xe81(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe86(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe8a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe8a(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movups 0xe81(%rip),%xmm0
movups %xmm0,(%rsp,%rax,1)
movups 0xe86(%rip),%xmm0
movups %xmm0,0x10(%rsp,%rax,1)
movups 0xe8a(%rip),%xmm0
movups %xmm0,0x20(%rsp,%rax,1)
movups 0xe8e(%rip),%xmm0
movups %xmm0,0x30(%rsp,%rax,1)
movups 0xe92(%rip),%xmm0
movups %xmm0,0x40(%rsp,%rax,1)
movups 0xe94(%rip),%xmm0
movups %xmm0,0x4e(%rsp,%rax,1)
lea    0xdda(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_socket@plt>
add    $0x3f40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"HTTP/1.1 401 Unauthorization\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [33 x i8] c"WWW-Authenticate: Basic realm=\0D\0A\00"
@.str.3 = [60 x i8] c"<HTML><HEAD><TITLE>Unauthorization Request</TITLE></HEAD>\0D\0A\00"
@.str.4 = [94 x i8] c"<BODY><P>Client did't authorized by server,please check your usr and pwd.</P></BODY></HTML>\0D\0A\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @Unauthorized_response(i32 %0) {
%2 = alloca i32
%3 = alloca [8096 x i8]
%4 = alloca [8096 x i8]
store i32 %0, i32* %2
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @write_socket(i32 %7, i8* %8, i32 %10)
%12 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @write_socket(i32 %14, i8* %15, i32 %17)
%19 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @write_socket(i32 %21, i8* %22, i32 %24)
%26 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%27 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%29 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* %2
%35 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 @write_socket(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %2
%38 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%39 = getelementptr inbounds [8096 x i8], [8096 x i8]* %4, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = call i32 @write_socket(i32 %37, i8* %38, i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"HTTP/1.1 401 Unauthorization\0D\0A\00"
@.str.1 = [27 x i8] c"Server: httpServer/0.1.1\0D\0A\00"
@.str.2 = [33 x i8] c"WWW-Authenticate: Basic realm=\0D\0A\00"
@.str.3 = [60 x i8] c"<HTML><HEAD><TITLE>Unauthorization Request</TITLE></HEAD>\0D\0A\00"
@.str.4 = [94 x i8] c"<BODY><P>Client did't authorized by server,please check your usr and pwd.</P></BODY></HTML>\0D\0A\00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @Unauthorized_response(i32 %0) {
%2 = alloca [8096 x i8]
%3 = alloca [8096 x i8]
%4 = getelementptr inbounds [8096 x i8], [8096 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = call i32 @strlen(i8* %4)
%7 = call i32 @write_socket(i32 %0, i8* %4, i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @write_socket(i32 %0, i8* %4, i32 %8)
%10 = call i32 @strlen(i8* %4)
%11 = call i32 @write_socket(i32 %0, i8* %4, i32 %10)
%12 = call i32 @strlen(i8* %5)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 %13
%15 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @write_socket(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = call i32 @strlen(i8* %5)
%18 = call i32 @write_socket(i32 %0, i8* %5, i32 %17)
ret void
}