#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*/ exit(int);
int posix_memalign(void **, int, int);
int /*<<< orphan*/ printf(char *);
void c_zeros_align(char **ptrA, int size) {
  void *temp;
  int err = posix_memalign(&temp, 64, size);
  if (err != 0) {
    printf("Memory allocation error");
    exit(1);
  }
  *ptrA = temp;
  char *A = *ptrA;
  int i;
  for (i = 0; i < size; i++)
    A[i] = 0;
}


x86 assembly (clang, -O0):
<c_zeros_align>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    -0x18(%rbp),%rdi
mov    $0x40,%esi
call   1050 <posix_memalign@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1173 <c_zeros_align+0x43>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b6 <c_zeros_align+0x86>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1190 <c_zeros_align+0x60>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_zeros_align>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %ebx,%edx
call   1060 <posix_memalign@plt>
test   %eax,%eax
jne    1178 <c_zeros_align+0x38>
mov    (%rsp),%rdi
mov    %rdi,(%r14)
test   %ebx,%ebx
jle    1170 <c_zeros_align+0x30>
mov    %ebx,%edx
xor    %esi,%esi
call   1040 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Memory allocation error\00"
define void @c_zeros_align(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = call i32 @posix_memalign(i8** %5, i32 64, i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = load i8**, i8*** %3
store i8* %17, i8** %18
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
store i8* %20, i8** %7
store i32 0, i32* %8
br label %21
21: ; preds = %30, %16
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i8*, i8** %7
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %25
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %21
33: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Memory allocation error\00"
define void @c_zeros_align(i8** nocapture writeonly %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @posix_memalign(i8** %3, i32 64, i32 %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = load i8*, i8** %3
store i8* %11, i8** %0
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %13, %10
ret void
}