#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int const);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main() {
  char *buffer;
  const int bsize = 27;
  int a;
  buffer = (char *)malloc(sizeof(char) * bsize);
  if (buffer == NULL) {
    fprintf(stderr, "Unable to allocate %d piddly bytes\n", bsize);
    exit(1);
  }
  for (a = 0; a < 26; a++)
    *(buffer + a) = 'A' + a;
  *(buffer + a) = '\0';
  printf("'%s' created\n", buffer);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1b,-0x14(%rbp)
mov    $0x1b,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1193 <main+0x53>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    $0x1b,%edx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x1a,-0x18(%rbp)
jge    11c5 <main+0x85>
mov    -0x18(%rbp),%eax
add    $0x41,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119a <main+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1b,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1185 <main+0x45>
movaps 0xea9(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x5857565554535251,%rcx
56 57 58
mov    %rcx,0x10(%rax)
movw   $0x5a59,0x18(%rax)
movb   $0x0,0x1a(%rax)
lea    0xebb(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x1b,%edx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Unable to allocate %d piddly bytes\0A\00"
@.str.1 = [14 x i8] c"'%s' created\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 27, i32* %3
%5 = call i64 @malloc(i32 27)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 27)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
store i32 0, i32* %4
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 26
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* %4
%19 = add nsw i32 65, %18
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %14
28: ; preds = %14
%29 = load i8*, i8** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
%33 = load i8*, i8** %2
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %33)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Unable to allocate %d piddly bytes\0A\00"
@.str.1 = [14 x i8] c"'%s' created\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 27)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %18, label %4
4: ; preds = %0
%5 = inttoptr i64 %1 to <16 x i8>*
store <16 x i8> <i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79, i8 80>, <16 x i8>* %5
%6 = getelementptr inbounds i8, i8* %2, i64 16
store i8 81, i8* %6
%7 = getelementptr inbounds i8, i8* %2, i64 17
store i8 82, i8* %7
%8 = getelementptr inbounds i8, i8* %2, i64 18
store i8 83, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 19
store i8 84, i8* %9
%10 = getelementptr inbounds i8, i8* %2, i64 20
store i8 85, i8* %10
%11 = getelementptr inbounds i8, i8* %2, i64 21
store i8 86, i8* %11
%12 = getelementptr inbounds i8, i8* %2, i64 22
store i8 87, i8* %12
%13 = getelementptr inbounds i8, i8* %2, i64 23
store i8 88, i8* %13
%14 = getelementptr inbounds i8, i8* %2, i64 24
store i8 89, i8* %14
%15 = getelementptr inbounds i8, i8* %2, i64 25
store i8 90, i8* %15
%16 = getelementptr inbounds i8, i8* %2, i64 26
store i8 0, i8* %16
%17 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
18: ; preds = %0
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 27)
%21 = tail call i32 @exit(i32 1)
unreachable
}