#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*/ free(char *);
char *malloc(unsigned int);
scalar_t__ sendString(int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
unsigned int strlen(char *);
int sendHeader(int sockfd, char *message, char *value) {
  unsigned int header_length = strlen(message) + strlen(value);
  char *header = malloc(header_length + 5);
  sprintf(header, "%s: %s\r\n", message, value);
  int ret = 0;
  if (sendString(sockfd, header) < 0)
    ret = -1;
  free(header);
  return ret;
}


x86 assembly (clang, -O0):
<sendHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
add    $0x5,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe5c(%rip),%rsi
call   1070 <sprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1040 <sendString@plt>
cmp    $0x0,%rax
jge    11cd <sendHeader+0x7d>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendHeader>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x5,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
lea    0xe79(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
call   1040 <sendString@plt>
mov    %rax,%rbx
sar    $0x3f,%rbx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s: %s\0D\0A\00"
define i32 @sendHeader(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
%14 = add i32 %11, %13
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = add i32 %15, 5
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
store i32 0, i32* %9
%22 = load i32, i32* %4
%23 = load i8*, i8** %8
%24 = call i64 @sendString(i32 %22, i8* %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %3
store i32 -1, i32* %9
br label %27
27: ; preds = %26, %3
%28 = load i8*, i8** %8
%29 = call i32 @free(i8* %28)
%30 = load i32, i32* %9
ret i32 %30
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s: %s\0D\0A\00"
define i32 @sendHeader(i32 %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* %2)
%6 = add i32 %4, 5
%7 = add i32 %6, %5
%8 = tail call i8* @malloc(i32 %7)
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%10 = tail call i64 @sendString(i32 %0, i8* %8)
%11 = ashr i64 %10, 63
%12 = trunc i64 %11 to i32
%13 = tail call i32 @free(i8* %8)
ret i32 %12
}