#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*/ printf(char *, ...);
int getBytes(char *buf) {
  int i;
  for (i = 0; i < 1024; ++i) {
    buf[i] = 'a' + (i % 26);
    printf("%c", buf[i]);
  }
  printf("\n");
  return 1024;
}


x86 assembly (clang, -O0):
<getBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x400,-0xc(%rbp)
jge    1171 <getBytes+0x61>
mov    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <getBytes+0x13>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x400,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBytes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x61,%r15b
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzwl %bx,%eax
imul   $0x4ec5,%eax,%eax
shr    $0x13,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
mov    %r15d,%eax
sub    %cl,%al
mov    %al,(%r14,%rbp,1)
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    $0x1,%r15b
add    $0x1,%ebx
cmp    $0x400,%rbp
jne    1130 <getBytes+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x400,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @getBytes(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %23, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1024
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = load i32, i32* %3
%9 = srem i32 %8, 26
%10 = add nsw i32 97, %9
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 %11, i8* %15
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %7
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %4
26: ; preds = %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 1024
}

LLVM IR (-O2):
define i32 @getBytes(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %11, %2 ]
%4 = trunc i64 %3 to i16
%5 = urem i16 %4, 26
%6 = trunc i16 %5 to i8
%7 = add nuw nsw i8 %6, 97
%8 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 %7, i8* %8
%9 = zext i8 %7 to i32
%10 = tail call i32 @putchar(i32 %9)
%11 = add nuw nsw i64 %3, 1
%12 = icmp eq i64 %11, 1024
br i1 %12, label %13, label %2
13: ; preds = %2
%14 = tail call i32 @putchar(i32 10)
ret i32 1024
}