#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  char *buf;
  int i, n = 'A';
  buf = malloc(80);
  if (!buf)
    return EXIT_FAILURE;
  for (i = 0; i < 80; i++) {
    buf[i] = (char)n;
    (n == 'Z') ? n = 'A' : n++;
  }
  buf[80 - 1] = '\0';
  (void)puts(buf);
  free(buf);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x41,-0x18(%rbp)
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <main+0x40>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e4 <main+0xb4>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    11be <main+0x8e>
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x5a,-0x18(%rbp)
jne    11a7 <main+0x77>
movl   $0x41,-0x18(%rbp)
jmp    11b0 <main+0x80>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <main+0x47>
mov    -0x10(%rbp),%rax
movb   $0x0,0x4f(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x50,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11ca <main+0x9a>
mov    %rax,%rbx
mov    $0x41,%eax
mov    $0x3,%ecx
mov    $0x41,%edx
jmp    116a <main+0x3a>
nopl   0x0(%rax,%rax,1)
add    $0x4,%rcx
cmp    $0x53,%rcx
je     11ad <main+0x7d>
mov    %dl,-0x3(%rbx,%rcx,1)
lea    0x1(%rdx),%esi
cmp    $0x5a,%edx
cmove  %eax,%esi
lea    0x1(%rsi),%edx
cmp    $0x5a,%esi
cmove  %eax,%edx
mov    %sil,-0x2(%rbx,%rcx,1)
mov    %dl,-0x1(%rbx,%rcx,1)
mov    $0x41,%esi
cmp    $0x5a,%edx
je     1198 <main+0x68>
add    $0x1,%edx
mov    %edx,%esi
mov    %sil,(%rbx,%rcx,1)
mov    $0x41,%edx
cmp    $0x5a,%esi
je     1160 <main+0x30>
add    $0x1,%esi
mov    %esi,%edx
jmp    1160 <main+0x30>
movb   $0x0,0x4f(%rbx)
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e10(%rip),%rax
jmp    11d1 <main+0xa1>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 65, i32* %4
%5 = call i8* @malloc(i32 80)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = load i32, i32* @EXIT_FAILURE
store i32 %9, i32* %1
br label %40
10: ; preds = %0
store i32 0, i32* %3
br label %11
11: ; preds = %29, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 80
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32, i32* %4
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 90
br i1 %22, label %23, label %24
23: ; preds = %14
store i32 65, i32* %4
br label %27
24: ; preds = %14
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %27
27: ; preds = %24, %23
%28 = phi i32 [ 65, %23 ], [ %25, %24 ]
br label %29
29: ; preds = %27
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %11
32: ; preds = %11
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 79
store i8 0, i8* %34
%35 = load i8*, i8** %2
%36 = call i32 @puts(i8* %35)
%37 = load i8*, i8** %2
%38 = call i32 @free(i8* %37)
%39 = load i32, i32* @EXIT_SUCCESS
store i32 %39, i32* %1
br label %40
40: ; preds = %32, %8
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%2 = icmp eq i8* %1, null
br i1 %2, label %35, label %3
3: ; preds = %0, %3
%4 = phi i64 [ %29, %3 ], [ 0, %0 ]
%5 = phi i32 [ %28, %3 ], [ 65, %0 ]
%6 = trunc i32 %5 to i8
%7 = getelementptr inbounds i8, i8* %1, i64 %4
store i8 %6, i8* %7
%8 = icmp eq i32 %5, 90
%9 = add nsw i32 %5, 1
%10 = select i1 %8, i32 65, i32 %9
%11 = or i64 %4, 1
%12 = trunc i32 %10 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 %11
store i8 %12, i8* %13
%14 = icmp eq i32 %10, 90
%15 = add nsw i32 %10, 1
%16 = select i1 %14, i32 65, i32 %15
%17 = or i64 %4, 2
%18 = trunc i32 %16 to i8
%19 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 %18, i8* %19
%20 = icmp eq i32 %16, 90
%21 = add nsw i32 %16, 1
%22 = select i1 %20, i32 65, i32 %21
%23 = or i64 %4, 3
%24 = trunc i32 %22 to i8
%25 = getelementptr inbounds i8, i8* %1, i64 %23
store i8 %24, i8* %25
%26 = icmp eq i32 %22, 90
%27 = add nsw i32 %22, 1
%28 = select i1 %26, i32 65, i32 %27
%29 = add nuw nsw i64 %4, 4
%30 = icmp eq i64 %29, 80
br i1 %30, label %31, label %3
31: ; preds = %3
%32 = getelementptr inbounds i8, i8* %1, i64 79
store i8 0, i8* %32
%33 = tail call i32 @puts(i8* %1)
%34 = tail call i32 @free(i8* %1)
br label %35
35: ; preds = %0, %31
%36 = phi i32* [ @EXIT_SUCCESS, %31 ], [ @EXIT_FAILURE, %0 ]
%37 = load i32, i32* %36
ret i32 %37
}