#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*/ dcfree(char *);
scalar_t__ dcmalloc(int const);
int /*<<< orphan*/ dcmemset(char *, char, int const);
int /*<<< orphan*/ memoryDump();
int main() {
  const int na = 6, nb = 2, nc = 912, nd = 4;
  char *a = (char *)dcmalloc(na * sizeof(char));
  if (a)
    dcmemset(a, 'a', na);
  char *b = (char *)dcmalloc(nb * sizeof(char));
  if (b)
    dcmemset(b, 'b', nb);
  char *c = (char *)dcmalloc(nc * sizeof(char));
  if (c)
    dcmemset(c, 'c', nc);
  if (c)
    dcfree(c);
  char *d = (char *)dcmalloc(nd * sizeof(char));
  if (d)
    dcmemset(d, 'd', nd);
  memoryDump();
  if (b)
    dcfree(b);
  if (a)
    dcfree(a);
  if (d)
    dcfree(d);
  memoryDump();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x390,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
mov    $0x6,%edi
call   1050 <dcmalloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1197 <main+0x57>
mov    -0x20(%rbp),%rdi
mov    $0x61,%esi
mov    $0x6,%edx
call   1030 <dcmemset@plt>
mov    $0x2,%edi
call   1050 <dcmalloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c3 <main+0x83>
mov    -0x28(%rbp),%rdi
mov    $0x62,%esi
mov    $0x2,%edx
call   1030 <dcmemset@plt>
mov    $0x390,%edi
call   1050 <dcmalloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11ef <main+0xaf>
mov    -0x30(%rbp),%rdi
mov    $0x63,%esi
mov    $0x390,%edx
call   1030 <dcmemset@plt>
cmpq   $0x0,-0x30(%rbp)
je     1203 <main+0xc3>
mov    -0x30(%rbp),%rdi
call   1040 <dcfree@plt>
mov    $0x4,%edi
call   1050 <dcmalloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     122f <main+0xef>
mov    -0x38(%rbp),%rdi
mov    $0x64,%esi
mov    $0x4,%edx
call   1030 <dcmemset@plt>
mov    $0x0,%al
call   1060 <memoryDump@plt>
cmpq   $0x0,-0x28(%rbp)
je     124a <main+0x10a>
mov    -0x28(%rbp),%rdi
call   1040 <dcfree@plt>
cmpq   $0x0,-0x20(%rbp)
je     125e <main+0x11e>
mov    -0x20(%rbp),%rdi
call   1040 <dcfree@plt>
cmpq   $0x0,-0x38(%rbp)
je     1272 <main+0x132>
mov    -0x38(%rbp),%rdi
call   1040 <dcfree@plt>
mov    $0x0,%al
call   1060 <memoryDump@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x6,%edi
call   1050 <dcmalloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     1169 <main+0x29>
mov    %r14,%rdi
mov    $0x61,%esi
mov    $0x6,%edx
call   1030 <dcmemset@plt>
mov    $0x2,%edi
call   1050 <dcmalloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     118d <main+0x4d>
mov    %r15,%rdi
mov    $0x62,%esi
mov    $0x2,%edx
call   1030 <dcmemset@plt>
mov    $0x390,%edi
call   1050 <dcmalloc@plt>
test   %rax,%rax
je     11b9 <main+0x79>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x63,%esi
mov    $0x390,%edx
call   1030 <dcmemset@plt>
mov    %rbx,%rdi
call   1040 <dcfree@plt>
mov    $0x4,%edi
call   1050 <dcmalloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11dd <main+0x9d>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x4,%edx
call   1030 <dcmemset@plt>
xor    %eax,%eax
call   1060 <memoryDump@plt>
test   %r15,%r15
je     11f1 <main+0xb1>
mov    %r15,%rdi
call   1040 <dcfree@plt>
test   %r14,%r14
je     11fe <main+0xbe>
mov    %r14,%rdi
call   1040 <dcfree@plt>
test   %rbx,%rbx
je     120b <main+0xcb>
mov    %rbx,%rdi
call   1040 <dcfree@plt>
xor    %eax,%eax
call   1060 <memoryDump@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %1
store i32 6, i32* %2
store i32 2, i32* %3
store i32 912, i32* %4
store i32 4, i32* %5
%10 = call i64 @dcmalloc(i32 6)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i8*, i8** %6
%16 = call i32 @dcmemset(i8* %15, i8 signext 97, i32 6)
br label %17
17: ; preds = %14, %0
%18 = call i64 @dcmalloc(i32 2)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = call i32 @dcmemset(i8* %23, i8 signext 98, i32 2)
br label %25
25: ; preds = %22, %17
%26 = call i64 @dcmalloc(i32 912)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i8*, i8** %8
%32 = call i32 @dcmemset(i8* %31, i8 signext 99, i32 912)
br label %33
33: ; preds = %30, %25
%34 = load i8*, i8** %8
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %8
%38 = call i32 @dcfree(i8* %37)
br label %39
39: ; preds = %36, %33
%40 = call i64 @dcmalloc(i32 4)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %9
%42 = load i8*, i8** %9
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i8*, i8** %9
%46 = call i32 @dcmemset(i8* %45, i8 signext 100, i32 4)
br label %47
47: ; preds = %44, %39
%48 = call i32 (...) @memoryDump()
%49 = load i8*, i8** %7
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i8*, i8** %7
%53 = call i32 @dcfree(i8* %52)
br label %54
54: ; preds = %51, %47
%55 = load i8*, i8** %6
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i8*, i8** %6
%59 = call i32 @dcfree(i8* %58)
br label %60
60: ; preds = %57, %54
%61 = load i8*, i8** %9
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i8*, i8** %9
%65 = call i32 @dcfree(i8* %64)
br label %66
66: ; preds = %63, %60
%67 = call i32 (...) @memoryDump()
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @dcmalloc(i32 6)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @dcmemset(i8* %2, i8 signext 97, i32 6)
br label %6
6: ; preds = %4, %0
%7 = tail call i64 @dcmalloc(i32 2)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @dcmemset(i8* %8, i8 signext 98, i32 2)
br label %12
12: ; preds = %10, %6
%13 = tail call i64 @dcmalloc(i32 912)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i32 @dcmemset(i8* %14, i8 signext 99, i32 912)
%18 = tail call i32 @dcfree(i8* %14)
br label %19
19: ; preds = %12, %16
%20 = tail call i64 @dcmalloc(i32 4)
%21 = inttoptr i64 %20 to i8*
%22 = icmp eq i64 %20, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @dcmemset(i8* %21, i8 signext 100, i32 4)
br label %25
25: ; preds = %23, %19
%26 = tail call i32 (...) @memoryDump()
br i1 %9, label %29, label %27
27: ; preds = %25
%28 = tail call i32 @dcfree(i8* %8)
br label %29
29: ; preds = %27, %25
br i1 %3, label %32, label %30
30: ; preds = %29
%31 = tail call i32 @dcfree(i8* %2)
br label %32
32: ; preds = %30, %29
br i1 %22, label %35, label %33
33: ; preds = %32
%34 = tail call i32 @dcfree(i8* %21)
br label %35
35: ; preds = %33, %32
%36 = tail call i32 (...) @memoryDump()
ret i32 0
}