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


x86 assembly (clang, -O0):
<SendMessage2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1070 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xec(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xec(%rbp),%edi
mov    -0xe8(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <write@plt>
cmp    $0x0,%rax
jge    1211 <SendMessage2+0xc1>
lea    0xe01(%rip),%rdi
call   1060 <perror@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SendMessage2>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1030 <strcpy@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xe69(%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     11cf <SendMessage2+0x7f>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe37(%rip),%rdi
call   1060 <perror@plt>
jmp    11c3 <SendMessage2+0x73>

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

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