#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 /*<<< orphan*/ writev(int, struct iovec *, int);
int main(void) {
  struct iovec buffers[3];
  buffers[0].iov_base = "hello";
  buffers[0].iov_len = 5;
  buffers[1].iov_base = " ";
  buffers[1].iov_len = 1;
  buffers[2].iov_base = "world\n";
  buffers[2].iov_len = 6;
  writev(1, buffers, 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x5,-0x38(%rbp)
lea    0xece(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
lea    0xebe(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x6,-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    0xee5(%rip),%rax
mov    %rax,(%rsp)
movl   $0x5,0x8(%rsp)
lea    0xed8(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x18(%rsp)
lea    0xec6(%rip),%rax
mov    %rax,0x20(%rsp)
movl   $0x6,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*, i32 }
@.str = [6 x i8] c"hello\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [7 x i8] c"world\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x %struct.iovec]
store i32 0, i32* %1
%3 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 0
%4 = getelementptr inbounds %struct.iovec, %struct.iovec* %3, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 0
%6 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i32 0, i32 1
store i32 5, i32* %6
%7 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 1
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 1
%10 = getelementptr inbounds %struct.iovec, %struct.iovec* %9, i32 0, i32 1
store i32 1, i32* %10
%11 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 2
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %11, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 2
%14 = getelementptr inbounds %struct.iovec, %struct.iovec* %13, i32 0, i32 1
store i32 6, i32* %14
%15 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %2, i64 0, i64 0
%16 = call i32 @writev(i32 1, %struct.iovec* %15, i32 3)
ret i32 0
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i32 }
@.str = [6 x i8] c"hello\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [7 x i8] c"world\0A\00"
define i32 @main() {
%1 = alloca [3 x %struct.iovec]
%2 = bitcast [3 x %struct.iovec]* %1 to i8*
%3 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 0
%4 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 0, i32 1
store i32 5, i32* %5
%6 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 1, i32 1
store i32 1, i32* %7
%8 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %1, i64 0, i64 2, i32 1
store i32 6, i32* %9
%10 = call i32 @writev(i32 1, %struct.iovec* %3, i32 3)
ret i32 0
}