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

/* Variables and functions */
int /*<<< orphan*/ free(struct iovec *);
void free_iovec(struct iovec **iov, int *iovlen) {
  int i;
  for (i = 0; i < *iovlen; i++)
    free((*iov)[i].iov_base);
  free(*iov);
}


x86 assembly (clang, -O0):
<free_iovec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1158 <free_iovec+0x48>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <free_iovec+0x17>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_iovec>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
cmpl   $0x0,(%rsi)
jle    1148 <free_iovec+0x38>
mov    %rsi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1130 <free_iovec+0x20>
mov    (%r14),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.iovec = type { %struct.iovec* }
define void @free_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
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = load %struct.iovec**, %struct.iovec*** %3
%13 = load %struct.iovec*, %struct.iovec** %12
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %13, i64 %15
%17 = getelementptr inbounds %struct.iovec, %struct.iovec* %16, i32 0, i32 0
%18 = load %struct.iovec*, %struct.iovec** %17
%19 = call i32 @free(%struct.iovec* %18)
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
%24 = load %struct.iovec**, %struct.iovec*** %3
%25 = load %struct.iovec*, %struct.iovec** %24
%26 = call i32 @free(%struct.iovec* %25)
ret void
}

LLVM IR (-O2):
%struct.iovec = type { %struct.iovec* }
define void @free_iovec(%struct.iovec** nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %2, %5
%6 = phi i64 [ %11, %5 ], [ 0, %2 ]
%7 = load %struct.iovec*, %struct.iovec** %0
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 %6, i32 0
%9 = load %struct.iovec*, %struct.iovec** %8
%10 = tail call i32 @free(%struct.iovec* %9)
%11 = add nuw nsw i64 %6, 1
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %5, label %15
15: ; preds = %5, %2
%16 = load %struct.iovec*, %struct.iovec** %0
%17 = tail call i32 @free(%struct.iovec* %16)
ret void
}