#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 */
struct iovec {
  char *iov_base;
  int iov_len;
};

/* Variables and functions */
int strlen(char *);
int /*<<< orphan*/ writev(int, struct iovec *, int);
void replyError(int s, char *buf) {
  struct iovec iv[3];
  iv[0].iov_base = "0, 0 : ERROR : ";
  iv[0].iov_len = 15;
  iv[1].iov_base = buf;
  iv[1].iov_len = strlen(buf);
  iv[2].iov_base = "\r\n";
  iv[2].iov_len = 2;
  writev(s, iv, 3);
}


x86 assembly (clang, -O0):
<replyError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0xf,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
lea    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x3,%edx
call   1030 <writev@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replyError>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
lea    0xed2(%rip),%rax
mov    %rax,(%rsp)
movl   $0xf,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,0x18(%rsp)
lea    0xebe(%rip),%rax
mov    %rax,0x20(%rsp)
movl   $0x2,0x28(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x3,%edx
call   1030 <writev@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.iovec = type { i8*, i32 }
@.str = [16 x i8] c"0, 0 : ERROR : \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @replyError(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [3 x %struct.iovec]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 0
%7 = getelementptr inbounds %struct.iovec, %struct.iovec* %6, i32 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 0
%9 = getelementptr inbounds %struct.iovec, %struct.iovec* %8, i32 0, i32 1
store i32 15, i32* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 1
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %11, i32 0, i32 0
store i8* %10, i8** %12
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 1
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %15, i32 0, i32 1
store i32 %14, i32* %16
%17 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 2
%18 = getelementptr inbounds %struct.iovec, %struct.iovec* %17, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 2
%20 = getelementptr inbounds %struct.iovec, %struct.iovec* %19, i32 0, i32 1
store i32 2, i32* %20
%21 = load i32, i32* %3
%22 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %5, i64 0, i64 0
%23 = call i32 @writev(i32 %21, %struct.iovec* %22, i32 3)
ret void
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i32 }
@.str = [16 x i8] c"0, 0 : ERROR : \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @replyError(i32 %0, i8* %1) {
%3 = alloca [3 x %struct.iovec]
%4 = bitcast [3 x %struct.iovec]* %3 to i8*
%5 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 0, i32 1
store i32 15, i32* %7
%8 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 1, i32 0
store i8* %1, i8** %8
%9 = tail call i32 @strlen(i8* %1)
%10 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 1, i32 1
store i32 %9, i32* %10
%11 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 2, i32 1
store i32 2, i32* %12
%13 = call i32 @writev(i32 %0, %struct.iovec* %5, i32 3)
ret void
}