#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int main() {
  {
    int n;
    int *q = &n;
    *q = 5;
  }
  {
    char *p = malloc(42);
    if (!p)
      exit(EXIT_FAILURE);
    *p = 'X';
    free(p);
  }
  {
    int *q;
    *q = 23;
  }
  {
    int *q = 0;
    *q = 23;
  }
  {
    char *p = malloc(42);
    if (!p)
      exit(EXIT_FAILURE);
    *p = 'X';
  }
  {
    char *p = malloc(42);
    if (!p)
      exit(EXIT_FAILURE);
    *p = 'X';
    free(p);
    *p = 'Y';
  }
  {
    int *q;
    {
      int n;
      q = &n;
    }
    *q = 5;
  }
  {
    char *p = malloc(42);
    char *r = p + 1;
    free(p);
    *r = 'X';
  }
  {
    int n;
    int *q = &n;
    ++q;
    *q = 5;
  }
  {
    char *p = malloc(42);
    if (!p)
      exit(EXIT_FAILURE);
    ++p;
    free(p);
  }
  {
    char *p = malloc(42);
    if (!p)
      exit(EXIT_FAILURE);
    p[99] = 'X';
    free(p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117b <main+0x4b>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
movb   $0x58,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
movl   $0x17,(%rax)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x17,(%rax)
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ce <main+0x9e>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x30(%rbp),%rax
movb   $0x58,(%rax)
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11fc <main+0xcc>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x38(%rbp),%rax
movb   $0x58,(%rax)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
movb   $0x59,(%rax)
lea    -0x44(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movl   $0x5,(%rax)
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rax
movb   $0x58,(%rax)
lea    -0x5c(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movl   $0x5,(%rax)
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    1294 <main+0x164>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2a,%edi
call   1040 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    12d0 <main+0x1a0>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x78(%rbp),%rax
movb   $0x58,0x63(%rax)
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i8*
store i32 0, i32* %1
store i32* %2, i32** %3
%17 = load i32*, i32** %3
store i32 5, i32* %17
%18 = call i8* @malloc(i32 42)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %0
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %0
%25 = load i8*, i8** %4
store i8 88, i8* %25
%26 = load i8*, i8** %4
%27 = call i32 @free(i8* %26)
%28 = load i32*, i32** %5
store i32 23, i32* %28
store i32* null, i32** %6
%29 = load i32*, i32** %6
store i32 23, i32* %29
%30 = call i8* @malloc(i32 42)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = icmp ne i8* %31, null
br i1 %32, label %36, label %33
33: ; preds = %24
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %24
%37 = load i8*, i8** %7
store i8 88, i8* %37
%38 = call i8* @malloc(i32 42)
store i8* %38, i8** %8
%39 = load i8*, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %44, label %41
41: ; preds = %36
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %36
%45 = load i8*, i8** %8
store i8 88, i8* %45
%46 = load i8*, i8** %8
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %8
store i8 89, i8* %48
store i32* %10, i32** %9
%49 = load i32*, i32** %9
store i32 5, i32* %49
%50 = call i8* @malloc(i32 42)
store i8* %50, i8** %11
%51 = load i8*, i8** %11
%52 = getelementptr inbounds i8, i8* %51, i64 1
store i8* %52, i8** %12
%53 = load i8*, i8** %11
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %12
store i8 88, i8* %55
store i32* %13, i32** %14
%56 = load i32*, i32** %14
%57 = getelementptr inbounds i32, i32* %56, i32 1
store i32* %57, i32** %14
%58 = load i32*, i32** %14
store i32 5, i32* %58
%59 = call i8* @malloc(i32 42)
store i8* %59, i8** %15
%60 = load i8*, i8** %15
%61 = icmp ne i8* %60, null
br i1 %61, label %65, label %62
62: ; preds = %44
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %44
%66 = load i8*, i8** %15
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %15
%68 = load i8*, i8** %15
%69 = call i32 @free(i8* %68)
%70 = call i8* @malloc(i32 42)
store i8* %70, i8** %16
%71 = load i8*, i8** %16
%72 = icmp ne i8* %71, null
br i1 %72, label %76, label %73
73: ; preds = %65
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %65
%77 = load i8*, i8** %16
%78 = getelementptr inbounds i8, i8* %77, i64 99
store i8 88, i8* %78
%79 = load i8*, i8** %16
%80 = call i32 @free(i8* %79)
ret i32 0
}

LLVM IR (-O2):