#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 httpWrite(int, char const *, int, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *,
                            unsigned short, int, char const *);
int strlen(char const *);
int soapPostSubmit(int fd, const char *url, const char *host,
                   unsigned short port, const char *action, const char *body) {
  int bodysize;
  char headerbuf[1024];
  bodysize = strlen(body);
  snprintf(headerbuf, 1024,
           "POST %s HTTP/1.1\r\n"
           "HOST: %s:%d\r\n"
           "Content-length: %d\r\n"
           "Content-Type: text/xml\r\n"
           "SOAPAction: \"%s\"\r\n"
           "\r\n",
           url, host, port, bodysize, action);
  return httpWrite(fd, body, bodysize, headerbuf);
}


x86 assembly (clang, -O0):
<soapPostSubmit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %cx,%ax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x1a(%rbp),%r9w
mov    -0x34(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    $0x400,%esi
lea    0xe77(%rip),%rdx
movzwl %r9w,%r9d
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <snprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    -0x440(%rbp),%rcx
call   1050 <httpWrite@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<soapPostSubmit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %edi,0xc(%rsp)
mov    %r9,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
lea    0xe9a(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rbp,%rcx
mov    %r12,%r8
mov    %r15d,%r9d
push   %r14
push   %r13
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r13d,%edx
lea    0x10(%rsp),%rcx
call   1050 <httpWrite@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [96 x i8] c"POST %s HTTP/1.1\0D\0AHOST: %s:%d\0D\0AContent-length: %d\0D\0AContent-Type: text/xml\0D\0ASOAPAction: \22%s\22\0D\0A\0D\0A\00"
define i32 @soapPostSubmit(i32 %0, i8* %1, i8* %2, i16 zeroext %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i16
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca [1024 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i16 %3, i16* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%15 = load i8*, i8** %12
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %13
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%18 = load i8*, i8** %8
%19 = load i8*, i8** %9
%20 = load i16, i16* %10
%21 = load i32, i32* %13
%22 = load i8*, i8** %11
%23 = call i32 @snprintf(i8* %17, i32 1024, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19, i16 zeroext %20, i32 %21, i8* %22)
%24 = load i32, i32* %7
%25 = load i8*, i8** %12
%26 = load i32, i32* %13
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%28 = call i32 @httpWrite(i32 %24, i8* %25, i32 %26, i8* %27)
ret i32 %28
}

LLVM IR (-O2):
@.str = [96 x i8] c"POST %s HTTP/1.1\0D\0AHOST: %s:%d\0D\0AContent-length: %d\0D\0AContent-Type: text/xml\0D\0ASOAPAction: \22%s\22\0D\0A\0D\0A\00"
define i32 @soapPostSubmit(i32 %0, i8* %1, i8* %2, i16 zeroext %3, i8* %4, i8* %5) {
%7 = alloca [1024 x i8]
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = tail call i32 @strlen(i8* %5)
%10 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i16 zeroext %3, i32 %9, i8* %4)
%11 = call i32 @httpWrite(i32 %0, i8* %5, i32 %9, i8* %8)
ret i32 %11
}