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

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ assert(int);
struct iovec *malloc(int);
size_t strlen(char *);
size_t writev(int /*<<< orphan*/, struct iovec *, int);
int main(int argc, char *argv[]) {
  if (argc < 2)
    return 0;
  struct iovec *iovs = malloc(argc);
  assert(iovs != NULL);
  int i;
  size_t cnt = 1;
  for (i = 0; i < argc - 1; ++i) {
    iovs[i].iov_base = argv[i + 1];
    iovs[i].iov_len = strlen(argv[i + 1]);
    cnt += iovs[i].iov_len;
  }
  iovs[i].iov_base = "\n";
  iovs[i].iov_len = 1;
  assert(cnt == writev(STDOUT_FILENO, iovs, i + 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1290 <main+0x150>
mov    -0x8(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x1,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1222 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <main+0x59>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
lea    0xdc8(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movq   $0x1,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
call   1030 <writev@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jl     11f8 <main+0xb8>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
call   1060 <malloc@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    %rbx,(%rsp)
lea    -0x1(%rbx),%r13d
lea    0x0(,%r13,8),%rbp
mov    $0x1,%ebx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x8(%r15,%r14,1),%rdi
mov    %rdi,(%r12,%r14,2)
call   1040 <strlen@plt>
mov    %rax,0x8(%r12,%r14,2)
add    %rax,%rbx
add    $0x8,%r14
cmp    %r14,%rbp
jne    1190 <main+0x50>
shl    $0x4,%r13
lea    0xe46(%rip),%rax
mov    %rax,(%r12,%r13,1)
movq   $0x1,0x8(%r12,%r13,1)
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
mov    (%rsp),%rdx
call   1030 <writev@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1050 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.iovec = type { i8*, i64 }
@.str = [2 x i8] c"\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.iovec*
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %79
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call %struct.iovec* @malloc(i32 %13)
store %struct.iovec* %14, %struct.iovec** %6
%15 = load %struct.iovec*, %struct.iovec** %6
%16 = icmp ne %struct.iovec* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
store i64 1, i64* %8
store i32 0, i32* %7
br label %19
19: ; preds = %56, %12
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %59
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %25, i64 %28
%30 = load i8*, i8** %29
%31 = load %struct.iovec*, %struct.iovec** %6
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds %struct.iovec, %struct.iovec* %31, i64 %33
%35 = getelementptr inbounds %struct.iovec, %struct.iovec* %34, i32 0, i32 0
store i8* %30, i8** %35
%36 = load i8**, i8*** %5
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %36, i64 %39
%41 = load i8*, i8** %40
%42 = call i64 @strlen(i8* %41)
%43 = load %struct.iovec*, %struct.iovec** %6
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds %struct.iovec, %struct.iovec* %43, i64 %45
%47 = getelementptr inbounds %struct.iovec, %struct.iovec* %46, i32 0, i32 1
store i64 %42, i64* %47
%48 = load %struct.iovec*, %struct.iovec** %6
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds %struct.iovec, %struct.iovec* %48, i64 %50
%52 = getelementptr inbounds %struct.iovec, %struct.iovec* %51, i32 0, i32 1
%53 = load i64, i64* %52
%54 = load i64, i64* %8
%55 = add i64 %54, %53
store i64 %55, i64* %8
br label %56
56: ; preds = %24
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %19
59: ; preds = %19
%60 = load %struct.iovec*, %struct.iovec** %6
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds %struct.iovec, %struct.iovec* %60, i64 %62
%64 = getelementptr inbounds %struct.iovec, %struct.iovec* %63, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %64
%65 = load %struct.iovec*, %struct.iovec** %6
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds %struct.iovec, %struct.iovec* %65, i64 %67
%69 = getelementptr inbounds %struct.iovec, %struct.iovec* %68, i32 0, i32 1
store i64 1, i64* %69
%70 = load i64, i64* %8
%71 = load i32, i32* @STDOUT_FILENO
%72 = load %struct.iovec*, %struct.iovec** %6
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
%75 = call i64 @writev(i32 %71, %struct.iovec* %72, i32 %74)
%76 = icmp eq i64 %70, %75
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
store i32 0, i32* %3
br label %79
79: ; preds = %59, %11
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i64 }
@.str = [2 x i8] c"\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %30, label %4
4: ; preds = %2
%5 = tail call %struct.iovec* @malloc(i32 %0)
%6 = icmp ne %struct.iovec* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %4, %11
%12 = phi i64 [ 0, %4 ], [ %14, %11 ]
%13 = phi i64 [ 1, %4 ], [ %20, %11 ]
%14 = add nuw nsw i64 %12, 1
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 %12, i32 0
store i8* %16, i8** %17
%18 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%19 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 %12, i32 1
store i64 %18, i64* %19
%20 = add i64 %18, %13
%21 = icmp eq i64 %14, %10
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 %10, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 %10, i32 1
store i64 1, i64* %24
%25 = load i32, i32* @STDOUT_FILENO
%26 = tail call i64 @writev(i32 %25, %struct.iovec* %5, i32 %0)
%27 = icmp eq i64 %20, %26
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
br label %30
30: ; preds = %2, %22
ret i32 0
}