#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*/ strcat(char *, char *);
int strlen(char *);
const char *shttp(char buf[4096], int cap, char *METHOD, char *path,
                  char *content, int *size) {
  strcat(buf, "GET / HTTP/1.0\r\n");
  strcat(buf, "\r\n");
  strcat(buf, "HOST: www.baidu.com\r\n");
  strcat(buf, "Content-Type: application/x-www-form-urlencoded\r\n");
  strcat(buf, "Content-Length: 0");
  strcat(buf, "\r\n");
  strcat(buf, "\r\n");
  strcat(buf, "\r\n\r\n");
  *size = strlen(buf);
  return buf;
}


x86 assembly (clang, -O0):
<shttp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xf13(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xecf(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xed3(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shttp>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%r14
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
call   1040 <strcat@plt>
lea    0xf2f(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xeeb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"GET / HTTP/1.0\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [22 x i8] c"HOST: www.baidu.com\0D\0A\00"
@.str.3 = [50 x i8] c"Content-Type: application/x-www-form-urlencoded\0D\0A\00"
@.str.4 = [18 x i8] c"Content-Length: 0\00"
@.str.5 = [5 x i8] c"\0D\0A\0D\0A\00"
define i8* @shttp(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32* %5, i32** %12
%13 = load i8*, i8** %7
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %7
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8*, i8** %7
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%21 = load i8*, i8** %7
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%23 = load i8*, i8** %7
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8*, i8** %7
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %7
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%29 = load i8*, i8** %7
%30 = call i32 @strlen(i8* %29)
%31 = load i32*, i32** %12
store i32 %30, i32* %31
%32 = load i8*, i8** %7
ret i8* %32
}

LLVM IR (-O2):
@.str = [17 x i8] c"GET / HTTP/1.0\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [22 x i8] c"HOST: www.baidu.com\0D\0A\00"
@.str.3 = [50 x i8] c"Content-Type: application/x-www-form-urlencoded\0D\0A\00"
@.str.4 = [18 x i8] c"Content-Length: 0\00"
@.str.5 = [5 x i8] c"\0D\0A\0D\0A\00"
define i8* @shttp(i8* returned %0, i32 %1, i8* nocapture readnone %2, i8* nocapture readnone %3, i8* nocapture readnone %4, i32* nocapture writeonly %5) {
%7 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 @strlen(i8* %0)
store i32 %15, i32* %5
ret i8* %0
}