#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*/ perror(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
void SendMessage(int msgsock, char *responsecode, char *version, char *key,
                 char *value) {
  char buf[(200)];
  strcpy(buf, version);
  strcat(buf, " ");
  strcat(buf, responsecode);
  strcat(buf, " OK\r\n");
  strcat(buf, key);
  strcat(buf, ": ");
  strcat(buf, value);
  strcat(buf, "\r\n\r\n");
  if (write(msgsock, buf, strlen(buf) + 1) < 0) {
    perror("writing on stream socket");
  }
}


x86 assembly (clang, -O0):
<SendMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0xf0(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xfc(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
lea    -0xf0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xfc(%rbp),%edi
mov    -0xf8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    124c <SendMessage+0xfc>
lea    0xdc7(%rip),%rdi
call   1060 <perror@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SendMessage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
mov    %r8,%r15
mov    %rcx,%r12
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1030 <strcpy@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
call   1040 <write@plt>
test   %rax,%rax
js     1202 <SendMessage+0xb2>
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe05(%rip),%rdi
call   1060 <perror@plt>
jmp    11f2 <SendMessage+0xa2>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [6 x i8] c" OK\0D\0A\00"
@.str.2 = [3 x i8] c": \00"
@.str.3 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.4 = [25 x i8] c"writing on stream socket\00"
define void @SendMessage(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [200 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%13 = load i8*, i8** %8
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%18 = load i8*, i8** %7
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%23 = load i8*, i8** %9
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%28 = load i8*, i8** %10
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %11, i64 0, i64 0
%35 = call i64 @strlen(i8* %34)
%36 = add nsw i64 %35, 1
%37 = call i64 @write(i32 %32, i8* %33, i64 %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %5
%40 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %5
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [6 x i8] c" OK\0D\0A\00"
@.str.2 = [3 x i8] c": \00"
@.str.3 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.4 = [25 x i8] c"writing on stream socket\00"
define void @SendMessage(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [200 x i8]
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* %2)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcat(i8* %7, i8* %1)
%11 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strcat(i8* %7, i8* %3)
%13 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @strcat(i8* %7, i8* %4)
%15 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = call i64 @strlen(i8* %7)
%17 = add nsw i64 %16, 1
%18 = call i64 @write(i32 %0, i8* %7, i64 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %5
%21 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %5
ret void
}