#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*/ AllocError(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ realloc(char *, unsigned int);
void *ReAllocate(void *optr, unsigned nchars) {
  optr = (void *)realloc((char *)optr, nchars);
  if (optr == (void *)0)
    AllocError("ReAllocate");
  if ((unsigned long)optr & 0x3)
    printf("Warning, pointer not aligned.\n");
  return optr;
}


x86 assembly (clang, -O0):
<ReAllocate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1166 <ReAllocate+0x36>
lea    0xe9f(%rip),%rdi
call   1030 <AllocError@plt>
mov    -0x8(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     1184 <ReAllocate+0x54>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReAllocate>:
push   %rbx
call   1050 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1151 <ReAllocate+0x21>
test   $0x3,%bl
je     115d <ReAllocate+0x2d>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
jmp    115d <ReAllocate+0x2d>
lea    0xea8(%rip),%rdi
call   1040 <AllocError@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ReAllocate\00"
@.str.1 = [31 x i8] c"Warning, pointer not aligned.\0A\00"
define i8* @ReAllocate(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = load i32, i32* %4
%7 = call i64 @realloc(i8* %5, i32 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @AllocError(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load i8*, i8** %3
%15 = ptrtoint i8* %14 to i64
%16 = and i64 %15, 3
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"ReAllocate\00"
@str = [30 x i8] c"Warning, pointer not aligned.\00"
define i8* @ReAllocate(i8* %0, i32 %1) {
%3 = tail call i64 @realloc(i8* %0, i32 %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @AllocError(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %12
7: ; preds = %2
%8 = and i64 %3, 3
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %5, %10, %7
%13 = inttoptr i64 %3 to i8*
ret i8* %13
}