#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 */
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int posix_memalign(void **, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  void *p = NULL;
  int err = posix_memalign(&p, 16, 128);
  if (err) {
    printf("error memalign");
    return -1;
  }
  printf("p = %lu\n", p);
  printf("p size = %ld\n", sizeof(p));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x10,%esi
mov    $0x80,%edx
call   1040 <posix_memalign@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1178 <main+0x58>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <main+0x84>
mov    -0x18(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x10,%esi
mov    $0x80,%edx
call   1040 <posix_memalign@plt>
test   %eax,%eax
je     115b <main+0x3b>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebx
jmp    1183 <main+0x63>
mov    0x8(%rsp),%rsi
lea    0xea8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"error memalign\00"
@.str.1 = [9 x i8] c"p = %lu\0A\00"
@.str.2 = [14 x i8] c"p size = %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%8 = call i32 @posix_memalign(i8** %6, i32 16, i32 128)
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %17
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 8)
store i32 0, i32* %3
br label %17
17: ; preds = %13, %11
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@.str = [15 x i8] c"error memalign\00"
@.str.1 = [9 x i8] c"p = %lu\0A\00"
@.str.2 = [14 x i8] c"p size = %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = call i32 @posix_memalign(i8** %3, i32 16, i32 128)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %13
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 8)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ -1, %7 ], [ 0, %9 ]
ret i32 %14
}