#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;
  void *iov_len;
};

/* Variables and functions */
void *strlen(char *);
int /*<<< orphan*/ writev(int, struct iovec *, int);
int main(int argc, char **argv) {
  static char part2[] = "THIS IS FROM WRITEV : http://www.ccplusplus.com/";
  static char part3[] = "]\n";
  static char part1[] = "[";
  struct iovec iov[3];
  iov[0].iov_base = part1;
  iov[0].iov_len = strlen(part1);
  iov[1].iov_base = part2;
  iov[1].iov_len = strlen(part2);
  iov[2].iov_base = part3;
  iov[2].iov_len = strlen(part3);
  writev(1, iov, 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2f37(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0x2f2c(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
lea    0x2ee8(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0x2edd(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
lea    0x2efe(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0x2ef3(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <writev@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0x2f49(%rip),%rdi
mov    %rdi,(%rsp)
call   1040 <strlen@plt>
mov    %rax,0x8(%rsp)
lea    0x2f00(%rip),%rdi
mov    %rdi,0x10(%rsp)
call   1040 <strlen@plt>
mov    %rax,0x18(%rsp)
lea    0x2f1b(%rip),%rdi
mov    %rdi,0x20(%rsp)
call   1040 <strlen@plt>
mov    %rax,0x28(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <writev@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.iovec = type { i8*, i8* }
@main.part2 = internal global [49 x i8] c"THIS IS FROM WRITEV : http://www.ccplusplus.com/\00"
@main.part3 = internal global [3 x i8] c"]\0A\00"
@main.part1 = internal global [2 x i8] c"[\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x %struct.iovec]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 0
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @main.part1, i64 0, i64 0), i8** %8
%9 = call i8* @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @main.part1, i64 0, i64 0))
%10 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 0
%11 = getelementptr inbounds %struct.iovec, %struct.iovec* %10, i32 0, i32 1
store i8* %9, i8** %11
%12 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 1
%13 = getelementptr inbounds %struct.iovec, %struct.iovec* %12, i32 0, i32 0
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @main.part2, i64 0, i64 0), i8** %13
%14 = call i8* @strlen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @main.part2, i64 0, i64 0))
%15 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 1
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %15, i32 0, i32 1
store i8* %14, i8** %16
%17 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, 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]* @main.part3, i64 0, i64 0), i8** %18
%19 = call i8* @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.part3, i64 0, i64 0))
%20 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 2
%21 = getelementptr inbounds %struct.iovec, %struct.iovec* %20, i32 0, i32 1
store i8* %19, i8** %21
%22 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %6, i64 0, i64 0
%23 = call i32 @writev(i32 1, %struct.iovec* %22, i32 3)
ret i32 0
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i8* }
@main.part2 = internal global [49 x i8] c"THIS IS FROM WRITEV : http://www.ccplusplus.com/\00"
@main.part3 = internal global [3 x i8] c"]\0A\00"
@main.part1 = internal global [2 x i8] c"[\00"
define i32 @main(i32 %0, i8** nocapture readnone %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 ([2 x i8], [2 x i8]* @main.part1, i64 0, i64 0), i8** %6
%7 = tail call i8* @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @main.part1, i64 0, i64 0))
%8 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 0, i32 1
store i8* %7, i8** %8
%9 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @main.part2, i64 0, i64 0), i8** %9
%10 = tail call i8* @strlen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @main.part2, i64 0, i64 0))
%11 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 1, i32 1
store i8* %10, i8** %11
%12 = 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]* @main.part3, i64 0, i64 0), i8** %12
%13 = tail call i8* @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.part3, i64 0, i64 0))
%14 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %3, i64 0, i64 2, i32 1
store i8* %13, i8** %14
%15 = call i32 @writev(i32 1, %struct.iovec* %5, i32 3)
ret i32 0
}