#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 {
  scalar_t__ iov_base;
};

/* Variables and functions */
int /*<<< orphan*/ free(scalar_t__);
void free_iov_data(struct iovec *iov, int count) {
  int len = count;
  if (iov == NULL)
    return;
  while (len--) {
    if (iov[len].iov_base)
      free(iov[len].iov_base);
  }
}


x86 assembly (clang, -O0):
<free_iov_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1135 <free_iov_data+0x25>
jmp    1177 <free_iov_data+0x67>
jmp    113a <free_iov_data+0x2a>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     1177 <free_iov_data+0x67>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1172 <free_iov_data+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    113a <free_iov_data+0x2a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_iov_data>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1159 <free_iov_data+0x49>
mov    %esi,%r14d
test   %esi,%esi
je     1159 <free_iov_data+0x49>
movslq %r14d,%rax
lea    (%rdi,%rax,8),%r15
add    $0xfffffffffffffff8,%r15
neg    %r14d
xor    %ebx,%ebx
jmp    1149 <free_iov_data+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffffffffffff,%rbx
cmp    %ebx,%r14d
je     1159 <free_iov_data+0x49>
mov    (%r15,%rbx,8),%rdi
test   %rdi,%rdi
je     1140 <free_iov_data+0x30>
call   1030 <free@plt>
jmp    1140 <free_iov_data+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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