#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 block_size(int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ proctal_darr_global_free(int *);
int *proctal_darr_global_realloc(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int main(void) {
  int *i = proctal_darr_global_realloc(NULL, sizeof(int));
  if (i == NULL) {
    fprintf(stderr, "Failed to allocate a new block.\n");
    return 1;
  }
  if (block_size(i) != sizeof(int)) {
    fprintf(stderr, "Wrong block size.\n");
    return 1;
  }
  *i = 0;
  proctal_darr_global_free(i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <proctal_darr_global_realloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118d <main+0x4d>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dd <main+0x9d>
mov    -0x10(%rbp),%rdi
call   1050 <block_size@plt>
cltq
cmp    $0x4,%rax
je     11c3 <main+0x83>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dd <main+0x9d>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <proctal_darr_global_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
mov    $0x4,%esi
call   1030 <proctal_darr_global_realloc@plt>
test   %rax,%rax
je     1174 <main+0x34>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <block_size@plt>
cmp    $0x4,%eax
jne    1186 <main+0x46>
movl   $0x0,(%rbx)
mov    %rbx,%rdi
call   1040 <proctal_darr_global_free@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
jmp    1196 <main+0x56>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Failed to allocate a new block.\0A\00"
@.str.1 = [19 x i8] c"Wrong block size.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @proctal_darr_global_realloc(i32* null, i32 4)
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %21
9: ; preds = %0
%10 = load i32*, i32** %2
%11 = call i32 @block_size(i32* %10)
%12 = sext i32 %11 to i64
%13 = icmp ne i64 %12, 4
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %21
17: ; preds = %9
%18 = load i32*, i32** %2
store i32 0, i32* %18
%19 = load i32*, i32** %2
%20 = call i32 @proctal_darr_global_free(i32* %19)
store i32 0, i32* %1
br label %21
21: ; preds = %17, %14, %6
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Failed to allocate a new block.\0A\00"
@.str.1 = [19 x i8] c"Wrong block size.\0A\00"
define i32 @main() {
%1 = tail call i32* @proctal_darr_global_realloc(i32* null, i32 4)
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %14
6: ; preds = %0
%7 = tail call i32 @block_size(i32* %1)
%8 = icmp eq i32 %7, 4
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %6
store i32 0, i32* %1
%13 = tail call i32 @proctal_darr_global_free(i32* %1)
br label %14
14: ; preds = %12, %9, %3
%15 = phi i32 [ 1, %3 ], [ 1, %9 ], [ 0, %12 ]
ret i32 %15
}