#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) {
  if (iov == NULL)
    return;
  while (count--) {
    if (iov[count].iov_base)
      free(iov[count].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)
cmpq   $0x0,-0x8(%rbp)
jne    112f <free_iov_data+0x1f>
jmp    1171 <free_iov_data+0x61>
jmp    1134 <free_iov_data+0x24>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1171 <free_iov_data+0x61>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     116c <free_iov_data+0x5c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    1134 <free_iov_data+0x24>
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
store %struct.iovec* %0, %struct.iovec** %3
store i32 %1, i32* %4
%5 = load %struct.iovec*, %struct.iovec** %3
%6 = icmp eq %struct.iovec* %5, null
br i1 %6, label %7, label %8
7: ; preds = %2
br label %30
8: ; preds = %2
br label %9
9: ; preds = %29, %8
%10 = load i32, i32* %4
%11 = add nsw i32 %10, -1
store i32 %11, i32* %4
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load %struct.iovec*, %struct.iovec** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds %struct.iovec, %struct.iovec* %14, i64 %16
%18 = getelementptr inbounds %struct.iovec, %struct.iovec* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %13
%22 = load %struct.iovec*, %struct.iovec** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds %struct.iovec, %struct.iovec* %22, i64 %24
%26 = getelementptr inbounds %struct.iovec, %struct.iovec* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = call i32 @free(i64 %27)
br label %29
29: ; preds = %21, %13
br label %9
30: ; preds = %7, %9
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
}