#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ stderr;
int main() {
  int *test;
  if ((test = (int *)calloc(256, sizeof(int))) == NULL) {
    fprintf(stderr, "size full\n");
    return 0;
  }
  *++test = 10;
  fprintf(stderr, "%d", *test);
  free(test);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x100,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117f <main+0x4f>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
movl   $0xa,0x4(%rax)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x100,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1179 <main+0x49>
mov    %rax,%rbx
add    $0x4,%rbx
movl   $0xa,0x4(%rax)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1190 <main+0x60>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"size full\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i64 @calloc(i32 256, i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, 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 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %18
9: ; preds = %0
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i32 1
store i32* %11, i32** %2
store i32 10, i32* %11
%12 = load i32, i32* @stderr
%13 = load i32*, i32** %2
%14 = load i32, i32* %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %2
%17 = call i32 @free(i32* %16)
store i32 0, i32* %1
br label %18
18: ; preds = %9, %6
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"size full\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i64 @calloc(i32 256, i32 4)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %0
%7 = inttoptr i64 %1 to i32*
%8 = getelementptr inbounds i32, i32* %7, i64 1
store i32 10, i32* %8
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
%11 = tail call i32 @free(i32* %8)
br label %12
12: ; preds = %6, %3
ret i32 0
}