void foo(void **p) {
  posix_memalign();
  posix_memalign(p);
  posix_memalign(0);
  posix_memalign(p, 1);
  posix_memalign(p, "foo");
  posix_memalign("gnu", "gcc");
  posix_memalign(1, p);
  posix_memalign(1, 2);
  posix_memalign(1, 2, 3);
  posix_memalign(p, p, p);
  posix_memalign(p, "qui", 3);
  posix_memalign(p, 1, 2);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
lea    0xea4(%rip),%rdi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1030 <posix_memalign@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <posix_memalign@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
lea    0xeaf(%rip),%rdi
lea    0xeac(%rip),%rsi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    $0x1,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <posix_memalign@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <posix_memalign@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <posix_memalign@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"gnu\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [4 x i8] c"qui\00"
define void @foo(i8** %0) {
%2 = alloca i8**
store i8** %0, i8*** %2
%3 = call i32 (...) @posix_memalign()
%4 = load i8**, i8*** %2
%5 = call i32 (i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, ...)*)(i8** %4)
%6 = call i32 (i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, ...)*)(i32 0)
%7 = load i8**, i8*** %2
%8 = call i32 (i8**, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i32, ...)*)(i8** %7, i32 1)
%9 = load i8**, i8*** %2
%10 = call i32 (i8**, i8*, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8*, ...)*)(i8** %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = load i8**, i8*** %2
%13 = call i32 (i32, i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i8**, ...)*)(i32 1, i8** %12)
%14 = call i32 (i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i32, ...)*)(i32 1, i32 2)
%15 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i32, i32, ...)*)(i32 1, i32 2, i32 3)
%16 = load i8**, i8*** %2
%17 = load i8**, i8*** %2
%18 = load i8**, i8*** %2
%19 = call i32 (i8**, i8**, i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8**, i8**, ...)*)(i8** %16, i8** %17, i8** %18)
%20 = load i8**, i8*** %2
%21 = call i32 (i8**, i8*, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8*, i32, ...)*)(i8** %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%22 = load i8**, i8*** %2
%23 = call i32 (i8**, i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i32, i32, ...)*)(i8** %22, i32 1, i32 2)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"gnu\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [4 x i8] c"qui\00"
define void @foo(i8** %0) {
%2 = tail call i32 (...) @posix_memalign()
%3 = tail call i32 (i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, ...)*)(i8** %0)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, ...)*)(i32 0)
%5 = tail call i32 (i8**, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i32, ...)*)(i8** %0, i32 1)
%6 = tail call i32 (i8**, i8*, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8*, ...)*)(i8** %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (i32, i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i8**, ...)*)(i32 1, i8** %0)
%9 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i32, ...)*)(i32 1, i32 2)
%10 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i32, i32, i32, ...)*)(i32 1, i32 2, i32 3)
%11 = tail call i32 (i8**, i8**, i8**, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8**, i8**, ...)*)(i8** %0, i8** %0, i8** %0)
%12 = tail call i32 (i8**, i8*, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i8*, i32, ...)*)(i8** %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%13 = tail call i32 (i8**, i32, i32, ...) bitcast (i32 (...)* @posix_memalign to i32 (i8**, i32, i32, ...)*)(i8** %0, i32 1, i32 2)
ret void
}