#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*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
char *realloc(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *p;
  char *progname;
  if (argc > 0)
    progname = argv[0];
  else
    progname = "";
  fprintf(stderr, "%s, line %d: %s", progname, 19,
          "-- Test realloc() for unusual situations\n");
  fprintf(stderr, "%s, line %d: %s", progname, 21,
          "Allocate 17 bytes with realloc(NULL, 17)\n");
  p = realloc(0, 17);
  if (p == 0)
    fprintf(stderr, "%s, line %d: %s", progname, 24,
            "*ERROR:Can't allocate 17 bytes. Must be bug in realloc()\n");
  fprintf(stderr, "%s, line %d: %s", progname, 26,
          "Write on allocated block\n");
  p[0] = p[16] = 17;
  fprintf(stderr, "%s, line %d: %s", progname, 28,
          "Increase block size with realloc(., 4711)\n");
  p = realloc(p, 4711);
  if (p == 0)
    fprintf(stderr, "%s, line %d: %s", progname, 31,
            "* ERROR: Could not increase block size\n");
  if (p[0] != 17 || p[16] != 17)
    fprintf(stderr, "%s, line %d: %s", progname, 33,
            "* ERROR: Data destroyed during p = realloc(p, 4711)\n");
  fprintf(stderr, "%s, line %d: %s", progname, 35,
          "Write on allocated block\n");
  p[4710] = 47;
  fprintf(stderr, "%s, line %d: %s", progname, 37,
          "Decrease block size with realloc(., 17)\n");
  p = realloc(p, 17);
  if (p == 0)
    fprintf(stderr, "%s, line %d: %s", progname, 40,
            "* ERROR: Could not decrease block size");
  else
    fprintf(stderr, "%s, line %d: %s", progname, 42, "Decreased block size\n");
  if (p[0] != 17 || p[16] != 17)
    fprintf(
        stderr, "%s, line %d: %s", progname, 44,
        "* ERROR: Data destroyed decreasing size with p = realloc(p, 17)\n");
  fprintf(stderr, "%s, line %d: %s", progname, 45,
          "Free block with realloc(., 0)\n");
  p = realloc(p, 0);
  if (p != 0)
    fprintf(stderr, "%s, line %d: %s", progname, 48,
            "realloc(p, 0) returns non null pointer\n");
  else
    fprintf(stderr, "%s, line %d: %s", progname, 50,
            "realloc(p, 0) returns null pointer\n");
  fprintf(stderr, "%s, line %d: %s", progname, 51,
          "Free pointer allocated with realloc(NULL, 0)\n");
  p = realloc(realloc(0, 0), 0);
  if (p != 0)
    fprintf(stderr, "%s, line %d: %s", progname, 54,
            "realloc(realloc(NULL, 0), 0) returned non null pointer\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1150 <main+0x30>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    115b <main+0x3b>
lea    0xf46(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe91(%rip),%rsi
mov    $0x13,%ecx
lea    0xe95(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x15,%ecx
lea    0xe9a(%rip),%r8
call   1030 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x11,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e7 <main+0xc7>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x18,%ecx
lea    0xe82(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe05(%rip),%rsi
mov    $0x1a,%ecx
lea    0xe97(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
movb   $0x11,0x10(%rax)
mov    -0x18(%rbp),%rax
movb   $0x11,(%rax)
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdd1(%rip),%rsi
mov    $0x1c,%ecx
lea    0xe7d(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1267,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1282 <main+0x162>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd8f(%rip),%rsi
mov    $0x1f,%ecx
lea    0xe66(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x11,%eax
jne    12a3 <main+0x183>
mov    -0x18(%rbp),%rax
movsbl 0x10(%rax),%eax
cmp    $0x11,%eax
je     12c8 <main+0x1a8>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd49(%rip),%rsi
mov    $0x21,%ecx
lea    0xe48(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd24(%rip),%rsi
mov    $0x23,%ecx
lea    0xdb6(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
movb   $0x2f,0x1266(%rax)
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xcf4(%rip),%rsi
mov    $0x25,%ecx
lea    0xe28(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x11,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1364 <main+0x244>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xcb2(%rip),%rsi
mov    $0x28,%ecx
lea    0xe0f(%rip),%r8
call   1030 <fprintf@plt>
jmp    1389 <main+0x269>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc88(%rip),%rsi
mov    $0x2a,%ecx
lea    0xe0c(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x11,%eax
jne    13aa <main+0x28a>
mov    -0x18(%rbp),%rax
movsbl 0x10(%rax),%eax
cmp    $0x11,%eax
je     13cf <main+0x2af>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc42(%rip),%rsi
mov    $0x2c,%ecx
lea    0xddc(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc1d(%rip),%rsi
mov    $0x2d,%ecx
lea    0xdf8(%rip),%r8
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1438 <main+0x318>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xbde(%rip),%rsi
mov    $0x30,%ecx
lea    0xdd8(%rip),%r8
call   1030 <fprintf@plt>
jmp    145d <main+0x33d>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xbb4(%rip),%rsi
mov    $0x32,%ecx
lea    0xdd6(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xb8f(%rip),%rsi
mov    $0x33,%ecx
lea    0xdd5(%rip),%r8
call   1030 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1040 <realloc@plt>
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     14cb <main+0x3ab>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xb46(%rip),%rsi
mov    $0x36,%ecx
lea    0xdba(%rip),%r8
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1131 <main+0x11>
mov    (%rsi),%r14
jmp    1138 <main+0x18>
lea    0xf65(%rip),%r14
mov    0x2ea1(%rip),%r12
mov    (%r12),%edi
lea    0xeb6(%rip),%rbx
lea    0xebf(%rip),%r8
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x13,%ecx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xece(%rip),%r8
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x15,%ecx
call   1030 <fprintf@plt>
xor    %edi,%edi
mov    $0x11,%esi
call   1040 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11af <main+0x8f>
mov    (%r12),%edi
lea    0xe65(%rip),%rsi
lea    0xec2(%rip),%r8
mov    %r14,%rdx
mov    $0x18,%ecx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xe46(%rip),%r15
lea    0xedd(%rip),%r8
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1a,%ecx
call   1030 <fprintf@plt>
movb   $0x11,0x10(%rbx)
movb   $0x11,(%rbx)
mov    (%r12),%edi
lea    0xed5(%rip),%r8
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x1c,%ecx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x1267,%esi
call   1040 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     120f <main+0xef>
cmpb   $0x11,(%rbx)
je     1233 <main+0x113>
jmp    1239 <main+0x119>
mov    (%r12),%edi
lea    0xde6(%rip),%rsi
lea    0xec2(%rip),%r8
mov    %r14,%rdx
mov    $0x1f,%ecx
call   1030 <fprintf@plt>
cmpb   $0x11,(%rbx)
jne    1239 <main+0x119>
cmpb   $0x11,0x10(%rbx)
je     1258 <main+0x138>
mov    (%r12),%edi
lea    0xdbc(%rip),%rsi
lea    0xec0(%rip),%r8
mov    %r14,%rdx
mov    $0x21,%ecx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xd9d(%rip),%r15
lea    0xe34(%rip),%r8
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x23,%ecx
call   1030 <fprintf@plt>
movb   $0x2f,0x1266(%rbx)
mov    (%r12),%edi
lea    0xeb4(%rip),%r8
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x25,%ecx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
call   1040 <realloc@plt>
mov    %rax,%rbx
mov    (%r12),%edi
lea    0xd49(%rip),%rsi
test   %rax,%rax
je     12cd <main+0x1ad>
lea    0xecd(%rip),%r8
mov    %r14,%rdx
mov    $0x2a,%ecx
jmp    12dc <main+0x1bc>
lea    0xe95(%rip),%r8
mov    %r14,%rdx
mov    $0x28,%ecx
call   1030 <fprintf@plt>
cmpb   $0x11,(%rbx)
jne    12ec <main+0x1cc>
cmpb   $0x11,0x10(%rbx)
je     130b <main+0x1eb>
mov    (%r12),%edi
lea    0xd09(%rip),%rsi
lea    0xea8(%rip),%r8
mov    %r14,%rdx
mov    $0x2c,%ecx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xcea(%rip),%rsi
lea    0xeca(%rip),%r8
mov    %r14,%rdx
mov    $0x2d,%ecx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <realloc@plt>
mov    (%r12),%edi
lea    0xcc1(%rip),%rsi
test   %rax,%rax
je     1355 <main+0x235>
lea    0xebb(%rip),%r8
mov    %r14,%rdx
mov    $0x30,%ecx
jmp    1364 <main+0x244>
lea    0xed2(%rip),%r8
mov    %r14,%rdx
mov    $0x32,%ecx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xc8c(%rip),%rsi
lea    0xed7(%rip),%r8
mov    %r14,%rdx
mov    $0x33,%ecx
call   1030 <fprintf@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <realloc@plt>
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <realloc@plt>
test   %rax,%rax
je     13bf <main+0x29f>
mov    (%r12),%edi
lea    0xc55(%rip),%rsi
lea    0xece(%rip),%r8
mov    %r14,%rdx
mov    $0x36,%ecx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s, line %d: %s\00"
@.str.2 = [42 x i8] c"-- Test realloc() for unusual situations\0A\00"
@.str.3 = [42 x i8] c"Allocate 17 bytes with realloc(NULL, 17)\0A\00"
@.str.4 = [58 x i8] c"*ERROR:Can't allocate 17 bytes. Must be bug in realloc()\0A\00"
@.str.5 = [26 x i8] c"Write on allocated block\0A\00"
@.str.6 = [43 x i8] c"Increase block size with realloc(., 4711)\0A\00"
@.str.7 = [40 x i8] c"* ERROR: Could not increase block size\0A\00"
@.str.8 = [53 x i8] c"* ERROR: Data destroyed during p = realloc(p, 4711)\0A\00"
@.str.9 = [41 x i8] c"Decrease block size with realloc(., 17)\0A\00"
@.str.10 = [39 x i8] c"* ERROR: Could not decrease block size\00"
@.str.11 = [22 x i8] c"Decreased block size\0A\00"
@.str.12 = [65 x i8] c"* ERROR: Data destroyed decreasing size with p = realloc(p, 17)\0A\00"
@.str.13 = [31 x i8] c"Free block with realloc(., 0)\0A\00"
@.str.14 = [40 x i8] c"realloc(p, 0) returns non null pointer\0A\00"
@.str.15 = [36 x i8] c"realloc(p, 0) returns null pointer\0A\00"
@.str.16 = [46 x i8] c"Free pointer allocated with realloc(NULL, 0)\0A\00"
@.str.17 = [56 x i8] c"realloc(realloc(NULL, 0), 0) returned non null pointer\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %7
br label %15
14: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
br label %15
15: ; preds = %14, %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %7
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 19, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %7
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 21, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%22 = call i8* @realloc(i8* null, i32 17)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %29
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %7
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 24, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %25, %15
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %7
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 16
store i8 17, i8* %34
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 17, i8* %36
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %7
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %38, i32 28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%40 = load i8*, i8** %6
%41 = call i8* @realloc(i8* %40, i32 4711)
store i8* %41, i8** %6
%42 = load i8*, i8** %6
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %48
44: ; preds = %29
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %7
%47 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %46, i32 31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %44, %29
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 17
br i1 %53, label %60, label %54
54: ; preds = %48
%55 = load i8*, i8** %6
%56 = getelementptr inbounds i8, i8* %55, i64 16
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 17
br i1 %59, label %60, label %64
60: ; preds = %54, %48
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %7
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %62, i32 33, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
br label %64
64: ; preds = %60, %54
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %7
%67 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %66, i32 35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i64 4710
store i8 47, i8* %69
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %7
%72 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %71, i32 37, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
%73 = load i8*, i8** %6
%74 = call i8* @realloc(i8* %73, i32 17)
store i8* %74, i8** %6
%75 = load i8*, i8** %6
%76 = icmp eq i8* %75, null
br i1 %76, label %77, label %81
77: ; preds = %64
%78 = load i32, i32* @stderr
%79 = load i8*, i8** %7
%80 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %79, i32 40, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %85
81: ; preds = %64
%82 = load i32, i32* @stderr
%83 = load i8*, i8** %7
%84 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %83, i32 42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %85
85: ; preds = %81, %77
%86 = load i8*, i8** %6
%87 = getelementptr inbounds i8, i8* %86, i64 0
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 17
br i1 %90, label %97, label %91
91: ; preds = %85
%92 = load i8*, i8** %6
%93 = getelementptr inbounds i8, i8* %92, i64 16
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %95, 17
br i1 %96, label %97, label %101
97: ; preds = %91, %85
%98 = load i32, i32* @stderr
%99 = load i8*, i8** %7
%100 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %99, i32 44, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %101
101: ; preds = %97, %91
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %7
%104 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %103, i32 45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
%105 = load i8*, i8** %6
%106 = call i8* @realloc(i8* %105, i32 0)
store i8* %106, i8** %6
%107 = load i8*, i8** %6
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %113
109: ; preds = %101
%110 = load i32, i32* @stderr
%111 = load i8*, i8** %7
%112 = call i32 @fprintf(i32 %110, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %111, i32 48, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0))
br label %117
113: ; preds = %101
%114 = load i32, i32* @stderr
%115 = load i8*, i8** %7
%116 = call i32 @fprintf(i32 %114, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %115, i32 50, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0))
br label %117
117: ; preds = %113, %109
%118 = load i32, i32* @stderr
%119 = load i8*, i8** %7
%120 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %119, i32 51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.16, i64 0, i64 0))
%121 = call i8* @realloc(i8* null, i32 0)
%122 = call i8* @realloc(i8* %121, i32 0)
store i8* %122, i8** %6
%123 = load i8*, i8** %6
%124 = icmp ne i8* %123, null
br i1 %124, label %125, label %129
125: ; preds = %117
%126 = load i32, i32* @stderr
%127 = load i8*, i8** %7
%128 = call i32 @fprintf(i32 %126, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %127, i32 54, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.17, i64 0, i64 0))
br label %129
129: ; preds = %125, %117
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s, line %d: %s\00"
@.str.2 = [42 x i8] c"-- Test realloc() for unusual situations\0A\00"
@.str.3 = [42 x i8] c"Allocate 17 bytes with realloc(NULL, 17)\0A\00"
@.str.4 = [58 x i8] c"*ERROR:Can't allocate 17 bytes. Must be bug in realloc()\0A\00"
@.str.5 = [26 x i8] c"Write on allocated block\0A\00"
@.str.6 = [43 x i8] c"Increase block size with realloc(., 4711)\0A\00"
@.str.7 = [40 x i8] c"* ERROR: Could not increase block size\0A\00"
@.str.8 = [53 x i8] c"* ERROR: Data destroyed during p = realloc(p, 4711)\0A\00"
@.str.9 = [41 x i8] c"Decrease block size with realloc(., 17)\0A\00"
@.str.10 = [39 x i8] c"* ERROR: Could not decrease block size\00"
@.str.11 = [22 x i8] c"Decreased block size\0A\00"
@.str.12 = [65 x i8] c"* ERROR: Data destroyed decreasing size with p = realloc(p, 17)\0A\00"
@.str.13 = [31 x i8] c"Free block with realloc(., 0)\0A\00"
@.str.14 = [40 x i8] c"realloc(p, 0) returns non null pointer\0A\00"
@.str.15 = [36 x i8] c"realloc(p, 0) returns null pointer\0A\00"
@.str.16 = [46 x i8] c"Free pointer allocated with realloc(NULL, 0)\0A\00"
@.str.17 = [56 x i8] c"realloc(realloc(NULL, 0), 0) returned non null pointer\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load i8*, i8** %1
br label %6
6: ; preds = %2, %4
%7 = phi i8* [ %5, %4 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 19, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 21, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i8* @realloc(i8* null, i32 17)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 24, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %14, %6
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%20 = getelementptr inbounds i8, i8* %12, i64 16
store i8 17, i8* %20
store i8 17, i8* %12
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%23 = tail call i8* @realloc(i8* %12, i32 4711)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %25, %17
%29 = load i8, i8* %23
%30 = icmp eq i8 %29, 17
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %23, i64 16
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 17
br i1 %34, label %38, label %35
35: ; preds = %31, %28
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 33, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
br label %38
38: ; preds = %35, %31
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%41 = getelementptr inbounds i8, i8* %23, i64 4710
store i8 47, i8* %41
%42 = load i32, i32* @stderr
%43 = tail call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 37, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
%44 = tail call i8* @realloc(i8* %23, i32 17)
%45 = icmp eq i8* %44, null
%46 = load i32, i32* @stderr
br i1 %45, label %47, label %49
47: ; preds = %38
%48 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 40, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %51
49: ; preds = %38
%50 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
%52 = load i8, i8* %44
%53 = icmp eq i8 %52, 17
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = getelementptr inbounds i8, i8* %44, i64 16
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 17
br i1 %57, label %61, label %58
58: ; preds = %54, %51
%59 = load i32, i32* @stderr
%60 = tail call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 44, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %61
61: ; preds = %58, %54
%62 = load i32, i32* @stderr
%63 = tail call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
%64 = tail call i8* @realloc(i8* %44, i32 0)
%65 = icmp eq i8* %64, null
%66 = load i32, i32* @stderr
br i1 %65, label %69, label %67
67: ; preds = %61
%68 = tail call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 48, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.14, i64 0, i64 0))
br label %71
69: ; preds = %61
%70 = tail call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 50, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0))
br label %71
71: ; preds = %69, %67
%72 = load i32, i32* @stderr
%73 = tail call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.16, i64 0, i64 0))
%74 = tail call i8* @realloc(i8* null, i32 0)
%75 = tail call i8* @realloc(i8* %74, i32 0)
%76 = icmp eq i8* %75, null
br i1 %76, label %80, label %77
77: ; preds = %71
%78 = load i32, i32* @stderr
%79 = tail call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 54, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.17, i64 0, i64 0))
br label %80
80: ; preds = %77, %71
ret i32 0
}