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

/* Variables and functions */
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ print_str_len(int /*<<< orphan*/, int /*<<< orphan*/);
void print_iovec(struct iovec *iov, int iovcnt) {
  int i;
  print("{");
  for (i = 0; i < iovcnt; i++) {
    if (i > 0)
      print(", ");
    print_str_len(iov[i].iov_base, iov[i].iov_len);
  }
  print("}");
}


x86 assembly (clang, -O0):
<print_iovec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <print@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118e <print_iovec+0x6e>
cmpl   $0x0,-0x10(%rbp)
jle    1164 <print_iovec+0x44>
lea    0xea3(%rip),%rdi
call   1040 <print@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%esi
call   1030 <print_str_len@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <print_iovec+0x22>
lea    0xe70(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_iovec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecd(%rip),%rdi
call   1040 <print@plt>
test   %ebp,%ebp
jle    117e <print_iovec+0x5e>
mov    (%rbx),%esi
mov    0x4(%rbx),%edi
call   1030 <print_str_len@plt>
cmp    $0x1,%ebp
je     117e <print_iovec+0x5e>
mov    %ebp,%r15d
add    $0xffffffffffffffff,%r15
xor    %ebp,%ebp
lea    0xea7(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <print@plt>
mov    0x8(%rbx,%rbp,8),%esi
mov    0xc(%rbx,%rbp,8),%edi
call   1030 <print_str_len@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <print_iovec+0x40>
lea    0xe80(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <print@plt>

LLVM IR (-O0):
%struct.iovec = type { i32, i32 }
@.str = [2 x i8] c"{\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [2 x i8] c"}\00"
define void @print_iovec(%struct.iovec* %0, i32 %1) {
%3 = alloca %struct.iovec*
%4 = alloca i32
%5 = alloca i32
store %struct.iovec* %0, %struct.iovec** %3
store i32 %1, i32* %4
%6 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %7
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = load %struct.iovec*, %struct.iovec** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds %struct.iovec, %struct.iovec* %17, i64 %19
%21 = getelementptr inbounds %struct.iovec, %struct.iovec* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.iovec*, %struct.iovec** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds %struct.iovec, %struct.iovec* %23, i64 %25
%27 = getelementptr inbounds %struct.iovec, %struct.iovec* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @print_str_len(i32 %22, i32 %28)
br label %30
30: ; preds = %16
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %7
33: ; preds = %7
%34 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.iovec = type { i32, i32 }
@.str = [2 x i8] c"{\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [2 x i8] c"}\00"
define void @print_iovec(%struct.iovec* nocapture %0, i32 %1) {
%3 = tail call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %23
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @print_str_len(i32 %8, i32 %10)
%12 = icmp eq i32 %1, 1
br i1 %12, label %23, label %13
13: ; preds = %5, %13
%14 = phi i64 [ %21, %13 ], [ 1, %5 ]
%15 = tail call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 %14, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 %14, i32 0
%19 = load i32, i32* %18
%20 = tail call i32 @print_str_len(i32 %17, i32 %19)
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %6
br i1 %22, label %23, label %13
23: ; preds = %13, %5, %2
%24 = tail call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}