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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int posix_memalign(void **, int, int);
void iobuf_alloc(int len_i, struct Pl_utl_iobuf **iobuf_ppo, char **buf_ppo) {
  void *buf_p;
  int rc;
  rc = posix_memalign((void **)&buf_p, 512, len_i);
  assert(buf_p);
  assert(0 == rc);
  *iobuf_ppo = (struct Pl_utl_iobuf *)buf_p;
  *buf_ppo = (char *)buf_p;
}


x86 assembly (clang, -O0):
<iobuf_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edx
lea    -0x20(%rbp),%rdi
mov    $0x200,%esi
call   1040 <posix_memalign@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%edi
call   1030 <assert@plt>
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iobuf_alloc>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%edx
lea    0x8(%rsp),%rdi
mov    $0x200,%esi
call   1040 <posix_memalign@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%edi
call   1030 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
sete   %dil
call   1030 <assert@plt>
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
mov    %rax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Pl_utl_iobuf = type { i32 }
define void @iobuf_alloc(i32 %0, %struct.Pl_utl_iobuf** %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.Pl_utl_iobuf**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store %struct.Pl_utl_iobuf** %1, %struct.Pl_utl_iobuf*** %5
store i8** %2, i8*** %6
%9 = load i32, i32* %4
%10 = call i32 @posix_memalign(i8** %7, i32 512, i32 %9)
store i32 %10, i32* %8
%11 = load i8*, i8** %7
%12 = ptrtoint i8* %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %8
%15 = icmp eq i32 0, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %7
%19 = bitcast i8* %18 to %struct.Pl_utl_iobuf*
%20 = load %struct.Pl_utl_iobuf**, %struct.Pl_utl_iobuf*** %5
store %struct.Pl_utl_iobuf* %19, %struct.Pl_utl_iobuf** %20
%21 = load i8*, i8** %7
%22 = load i8**, i8*** %6
store i8* %21, i8** %22
ret void
}

LLVM IR (-O2):
%struct.Pl_utl_iobuf = type { i32 }
define void @iobuf_alloc(i32 %0, %struct.Pl_utl_iobuf** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 @posix_memalign(i8** %4, i32 512, i32 %0)
%7 = load i8*, i8** %4
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = icmp eq i32 %6, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = bitcast i8** %4 to %struct.Pl_utl_iobuf**
%15 = load %struct.Pl_utl_iobuf*, %struct.Pl_utl_iobuf** %14
store %struct.Pl_utl_iobuf* %15, %struct.Pl_utl_iobuf** %1
%16 = bitcast i8** %2 to %struct.Pl_utl_iobuf**
store %struct.Pl_utl_iobuf* %15, %struct.Pl_utl_iobuf** %16
ret void
}