#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 */

/* Variables and functions */
int /*<<< orphan*/ err(int, char *, char const *, int, char const *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ posix_memalign(void **, size_t, size_t);
void *xmemalign_(size_t align, size_t size, const char *file, int line,
                 const char *func) {
  void *p;
  if ((errno = posix_memalign(&p, align, size)))
    err(1, "%s:%d (%s): malloc() failed", file, line, func);
  return p;
}


x86 assembly (clang, -O0):
<xmemalign_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x30(%rbp),%rdi
call   1040 <posix_memalign@plt>
mov    0x2e8d(%rip),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
je     117a <xmemalign_+0x5a>
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    $0x1,%edi
lea    0xe8b(%rip),%rsi
call   1030 <err@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmemalign_>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%rdx
mov    %rdi,%rsi
lea    0x8(%rsp),%rdi
call   1040 <posix_memalign@plt>
mov    0x2e99(%rip),%rcx
mov    %eax,(%rcx)
test   %eax,%eax
je     1166 <xmemalign_+0x46>
lea    0xeac(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r14,%r8
call   1030 <err@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [28 x i8] c"%s:%d (%s): malloc() failed\00"
define i8* @xmemalign_(i64 %0, i64 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i64 %0, i64* %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = call i32 @posix_memalign(i8** %11, i64 %12, i64 %13)
store i32 %14, i32* @errno
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %5
%17 = load i8*, i8** %8
%18 = load i32, i32* %9
%19 = load i8*, i8** %10
%20 = call i32 @err(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18, i8* %19)
br label %21
21: ; preds = %16, %5
%22 = load i8*, i8** %11
ret i8* %22
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [28 x i8] c"%s:%d (%s): malloc() failed\00"
define i8* @xmemalign_(i64 %0, i64 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = call i32 @posix_memalign(i8** %6, i64 %0, i64 %1)
store i32 %8, i32* @errno
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i32 @err(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3, i8* %4)
br label %12
12: ; preds = %10, %5
%13 = load i8*, i8** %6
ret i8* %13
}