#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int strlen(char *);
int phBuffer(char *sendbuf, char *account, char *password, char *version,
             char *host) {
  char temp[1000];
  memset(temp, 0, 1000);
  char *md5 = "61723192fe4e65dd69a1f0128b29751d";
  sprintf(
      temp,
      "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
      "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
      "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
      "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
      "<soap:Header>"
      "<AuthHeader xmlns=\"http://tempuri.org/\">"
      "<Account>%s</Account>"
      "<Password>%s</Password>"
      "</AuthHeader>"
      "</soap:Header>"
      "<soap:Body>"
      "<GetMiscInfo xmlns=\"http://tempuri.org/\">"
      "<clientversion>%s</clientversion>"
      "</GetMiscInfo>"
      "</soap:Body>"
      "</soap:Envelope>",
      account, md5, version);
  int len = strlen(temp);
  sprintf(sendbuf,
          "POST /userinfo.asmx HTTP/1.1\r\nHost: %s\r\n"
          "Content-Type: text/xml; charset=utf-8\r\nContent-Length: %d\r\n"
          "SOAPAction: \"http://tempuri.org/GetMiscInfo\"\r\n\r\n"
          "%s",
          host, len, temp);
  printf("=================================\n");
  printf("send: %s\n", sendbuf);
  printf("=================================\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<phBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
lea    0xe87(%rip),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x418(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x41c(%rbp),%ecx
lea    -0x410(%rbp),%r8
lea    0x101a(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    0x10a2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0x10b3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x10af(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phBuffer>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %r8,%r14
mov    %rcx,%r12
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1060 <memset@plt>
lea    0xe9c(%rip),%rsi
lea    0xe74(%rip),%rcx
mov    %r13,%rdi
mov    %rbx,%rdx
mov    %r12,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
lea    0x1041(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %eax,%ecx
mov    %r13,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0x10c8(%rip),%rdi
call   1030 <puts@plt>
lea    0x10b2(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10cd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"61723192fe4e65dd69a1f0128b29751d\00"
@.str.1 = [459 x i8] c"<?xml version=\221.0\22 encoding=\22utf-8\22?><soap:Envelope xmlns:xsi=\22http://www.w3.org/2001/XMLSchema-instance\22 xmlns:xsd=\22http://www.w3.org/2001/XMLSchema\22 xmlns:soap=\22http://schemas.xmlsoap.org/soap/envelope/\22><soap:Header><AuthHeader xmlns=\22http://tempuri.org/\22><Account>%s</Account><Password>%s</Password></AuthHeader></soap:Header><soap:Body><GetMiscInfo xmlns=\22http://tempuri.org/\22><clientversion>%s</clientversion></GetMiscInfo></soap:Body></soap:Envelope>\00"
@.str.2 = [150 x i8] c"POST /userinfo.asmx HTTP/1.1\0D\0AHost: %s\0D\0AContent-Type: text/xml; charset=utf-8\0D\0AContent-Length: %d\0D\0ASOAPAction: \22http://tempuri.org/GetMiscInfo\22\0D\0A\0D\0A%s\00"
@.str.3 = [35 x i8] c"=================================\0A\00"
@.str.4 = [10 x i8] c"send: %s\0A\00"
@.str.5 = [36 x i8] c"=================================\0A\0A\00"
define i32 @phBuffer(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [1000 x i8]
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 1000)
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %12
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%17 = load i8*, i8** %7
%18 = load i8*, i8** %12
%19 = load i8*, i8** %9
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([459 x i8], [459 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18, i8* %19)
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %13
%23 = load i8*, i8** %6
%24 = load i8*, i8** %10
%25 = load i32, i32* %13
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 %25, i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"61723192fe4e65dd69a1f0128b29751d\00"
@.str.1 = [459 x i8] c"<?xml version=\221.0\22 encoding=\22utf-8\22?><soap:Envelope xmlns:xsi=\22http://www.w3.org/2001/XMLSchema-instance\22 xmlns:xsd=\22http://www.w3.org/2001/XMLSchema\22 xmlns:soap=\22http://schemas.xmlsoap.org/soap/envelope/\22><soap:Header><AuthHeader xmlns=\22http://tempuri.org/\22><Account>%s</Account><Password>%s</Password></AuthHeader></soap:Header><soap:Body><GetMiscInfo xmlns=\22http://tempuri.org/\22><clientversion>%s</clientversion></GetMiscInfo></soap:Body></soap:Envelope>\00"
@.str.2 = [150 x i8] c"POST /userinfo.asmx HTTP/1.1\0D\0AHost: %s\0D\0AContent-Type: text/xml; charset=utf-8\0D\0AContent-Length: %d\0D\0ASOAPAction: \22http://tempuri.org/GetMiscInfo\22\0D\0A\0D\0A%s\00"
@.str.4 = [10 x i8] c"send: %s\0A\00"
@str = [34 x i8] c"=================================\00"
@str.6 = [35 x i8] c"=================================\0A\00"
define i32 @phBuffer(i8* %0, i8* %1, i8* nocapture readnone %2, i8* %3, i8* %4) {
%6 = alloca [1000 x i8]
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 1000)
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([459 x i8], [459 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %3)
%10 = call i32 @strlen(i8* %7)
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([150 x i8], [150 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %10, i8* %7)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}