#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 */
struct obstack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memcpy(void *, void *, size_t);
void *obstack_alloc(struct obstack *, size_t);
void *obstack_realloc(struct obstack *obstack, void *old, size_t old_size,
                      size_t new_size) {
  void *new;
  assert(old);
  assert(new_size > old_size);
  new = obstack_alloc(obstack, new_size);
  memcpy(new, old, old_size);
  return new;
}


x86 assembly (clang, -O0):
<obstack_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <obstack_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obstack_realloc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %r15d,%edi
call   1040 <assert@plt>
xor    %edi,%edi
cmp    %r14,%rbx
seta   %dil
call   1040 <assert@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <obstack_alloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.obstack = type { i32 }
define i8* @obstack_realloc(%struct.obstack* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca %struct.obstack*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
store %struct.obstack* %0, %struct.obstack** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i8*, i8** %6
%11 = ptrtoint i8* %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i64, i64* %8
%14 = load i64, i64* %7
%15 = icmp ugt i64 %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load %struct.obstack*, %struct.obstack** %5
%19 = load i64, i64* %8
%20 = call i8* @obstack_alloc(%struct.obstack* %18, i64 %19)
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i8*, i8** %6
%23 = load i64, i64* %7
%24 = call i32 @memcpy(i8* %21, i8* %22, i64 %23)
%25 = load i8*, i8** %9
ret i8* %25
}

LLVM IR (-O2):
%struct.obstack = type { i32 }
define i8* @obstack_realloc(%struct.obstack* %0, i8* %1, i64 %2, i64 %3) {
%5 = ptrtoint i8* %1 to i64
%6 = trunc i64 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ugt i64 %3, %2
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i8* @obstack_alloc(%struct.obstack* %0, i64 %3)
%12 = tail call i32 @memcpy(i8* %11, i8* %1, i64 %2)
ret i8* %11
}