#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);
int main(int argc, char *argv[]) {
  unsigned char y = 80;
  unsigned char a;
  a = 0;
  for (y = 80; y > 0; y--) {
    printf("LDA %04X\n", 0xC080 + a);
    a = y;
    a = a & 3;
    a = a << 1;
    printf("LDA %04X\n", 0xC081 + a);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x50,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
movb   $0x50,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jle    1192 <main+0x82>
movzbl -0x12(%rbp),%esi
add    $0xc080,%esi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x11(%rbp),%al
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
and    $0x3,%eax
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%esi
add    $0xc081,%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x11(%rbp),%al
add    $0xff,%al
mov    %al,-0x11(%rbp)
jmp    1132 <main+0x22>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0xb0,%bpl
mov    $0xa0,%r15b
lea    0xeda(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
and    $0xfe,%ebx
add    $0xc080,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r15d,%eax
and    $0x6,%al
movzbl %al,%ebx
lea    0xc081(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xfe,%r15b
inc    %bpl
jne    1130 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"LDA %04X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 80, i8* %6
store i8 0, i8* %7
store i8 80, i8* %6
br label %8
8: ; preds = %30, %2
%9 = load i8, i8* %6
%10 = zext i8 %9 to i32
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = load i8, i8* %7
%14 = zext i8 %13 to i32
%15 = add nsw i32 49280, %14
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8, i8* %6
store i8 %17, i8* %7
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = and i32 %19, 3
%21 = trunc i32 %20 to i8
store i8 %21, i8* %7
%22 = load i8, i8* %7
%23 = zext i8 %22 to i32
%24 = shl i32 %23, 1
%25 = trunc i32 %24 to i8
store i8 %25, i8* %7
%26 = load i8, i8* %7
%27 = zext i8 %26 to i32
%28 = add nsw i32 49281, %27
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %12
%31 = load i8, i8* %6
%32 = add i8 %31, -1
store i8 %32, i8* %6
br label %8
33: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"LDA %04X\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %11, %3 ]
%5 = phi i8 [ 80, %2 ], [ %14, %3 ]
%6 = and i32 %4, 254
%7 = add nuw nsw i32 %6, 49280
%8 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = shl i8 %5, 1
%10 = and i8 %9, 6
%11 = zext i8 %10 to i32
%12 = or i32 %11, 49281
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = add nsw i8 %5, -1
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %3
16: ; preds = %3
ret i32 0
}