#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ iovec_fixlast(int *, struct iovec **, void *);
int /*<<< orphan*/ iovec_free(int *, struct iovec **);
void *iovec_increase(int *, struct iovec **, size_t);
void *iovec_fix_increase_or_free(int *iovec_entries, struct iovec **iovector,
                                 void *last_ptr, size_t new_alloc) {
  void *new_ptr;
  iovec_fixlast(iovec_entries, iovector, last_ptr);
  if (!(new_ptr = iovec_increase(iovec_entries, iovector, new_alloc)))
    iovec_free(iovec_entries, iovector);
  return new_ptr;
}


x86 assembly (clang, -O0):
<iovec_fix_increase_or_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <iovec_fixlast@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <iovec_increase@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1185 <iovec_fix_increase_or_free+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <iovec_free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iovec_fix_increase_or_free>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <iovec_fixlast@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <iovec_increase@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1164 <iovec_fix_increase_or_free+0x34>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <iovec_free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.iovec = type { i32 }
define i8* @iovec_fix_increase_or_free(i32* %0, %struct.iovec** %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca %struct.iovec**
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store i32* %0, i32** %5
store %struct.iovec** %1, %struct.iovec*** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%10 = load i32*, i32** %5
%11 = load %struct.iovec**, %struct.iovec*** %6
%12 = load i8*, i8** %7
%13 = call i32 @iovec_fixlast(i32* %10, %struct.iovec** %11, i8* %12)
%14 = load i32*, i32** %5
%15 = load %struct.iovec**, %struct.iovec*** %6
%16 = load i64, i64* %8
%17 = call i8* @iovec_increase(i32* %14, %struct.iovec** %15, i64 %16)
store i8* %17, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %23, label %19
19: ; preds = %4
%20 = load i32*, i32** %5
%21 = load %struct.iovec**, %struct.iovec*** %6
%22 = call i32 @iovec_free(i32* %20, %struct.iovec** %21)
br label %23
23: ; preds = %19, %4
%24 = load i8*, i8** %9
ret i8* %24
}

LLVM IR (-O2):
%struct.iovec = type { i32 }
define i8* @iovec_fix_increase_or_free(i32* %0, %struct.iovec** %1, i8* %2, i64 %3) {
%5 = tail call i32 @iovec_fixlast(i32* %0, %struct.iovec** %1, i8* %2)
%6 = tail call i8* @iovec_increase(i32* %0, %struct.iovec** %1, i64 %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @iovec_free(i32* %0, %struct.iovec** %1)
br label %10
10: ; preds = %8, %4
ret i8* %6
}