#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*/ putchar(char);
void printExcelColumnName(int columnNumber) {
  int letter1 = columnNumber / (26 * 26);
  if (letter1 > 26) {
    letter1 = 26;
  }
  int letter2 = (columnNumber - letter1 * 26 * 26) / 26;
  if (letter2 == 0) {
    if (letter1 != 0) {
      letter2 = 26;
      letter1--;
    }
  } else if (letter2 == 27) {
    letter2 = 26;
  }
  int letter3 = columnNumber - letter1 * 26 * 26 - letter2 * 26;
  if (letter3 == 0) {
    letter3 = 26;
    letter2--;
  }
  if (letter1 > 0)
    putchar('A' - 1 + letter1);
  if (letter2 > 0)
    putchar('A' - 1 + letter2);
  putchar('A' - 1 + letter3);
  putchar('\n');
}


x86 assembly (clang, -O0):
<printExcelColumnName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2a4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x1a,-0x8(%rbp)
jle    113a <printExcelColumnName+0x2a>
movl   $0x1a,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x1a,-0x8(%rbp),%ecx
imul   $0x1a,%ecx,%ecx
sub    %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117a <printExcelColumnName+0x6a>
cmpl   $0x0,-0x8(%rbp)
je     1175 <printExcelColumnName+0x65>
movl   $0x1a,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <printExcelColumnName+0x80>
cmpl   $0x1b,-0xc(%rbp)
jne    118b <printExcelColumnName+0x7b>
movl   $0x1a,-0xc(%rbp)
jmp    1190 <printExcelColumnName+0x80>
mov    -0x4(%rbp),%eax
imul   $0x1a,-0x8(%rbp),%ecx
imul   $0x1a,%ecx,%ecx
sub    %ecx,%eax
imul   $0x1a,-0xc(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11bf <printExcelColumnName+0xaf>
movl   $0x1a,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11d7 <printExcelColumnName+0xc7>
mov    -0x8(%rbp),%eax
add    $0x40,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11ef <printExcelColumnName+0xdf>
mov    -0xc(%rbp),%eax
add    $0x40,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x40,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printExcelColumnName>:
push   %r14
push   %rbx
push   %rax
movslq %edi,%rdx
imul   $0x60f25deb,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x28,%rax
add    %ecx,%eax
cmp    $0x1a,%eax
mov    $0x1a,%ebx
cmovge %ebx,%eax
imul   $0xfffffd5c,%eax,%ecx
add    %ecx,%edx
add    $0x19,%edx
cmp    $0x32,%edx
ja     1160 <printExcelColumnName+0x50>
xor    %ecx,%ecx
sub    $0x1,%eax
cmovb  %ecx,%eax
mov    $0x1a,%ebx
cmovb  %ecx,%ebx
imul   $0xfffffd5c,%eax,%ecx
add    %edi,%ecx
jmp    1184 <printExcelColumnName+0x74>
add    %edi,%ecx
lea    -0x2be(%rcx),%edx
cmp    $0x1a,%edx
jb     1184 <printExcelColumnName+0x74>
movslq %ecx,%rdx
imul   $0x4ec4ec4f,%rdx,%rbx
mov    %rbx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rbx
add    %edx,%ebx
imul   $0xffffffe6,%ebx,%r14d
xor    %edx,%edx
add    %ecx,%r14d
sete   %dl
sub    %edx,%ebx
test   %eax,%eax
jle    11a0 <printExcelColumnName+0x90>
add    $0x40,%al
movsbl %al,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
jle    11af <printExcelColumnName+0x9f>
add    $0x40,%bl
movsbl %bl,%edi
call   1030 <putchar@plt>
lea    0x40(%r14),%eax
test   %r14d,%r14d
movzbl %al,%eax
mov    $0x5a,%ecx
cmovne %eax,%ecx
movsbl %cl,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @printExcelColumnName(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 676
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 26
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 26, i32* %3
br label %11
11: ; preds = %10, %1
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 26
%15 = mul nsw i32 %14, 26
%16 = sub nsw i32 %12, %15
%17 = sdiv i32 %16, 26
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %11
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
store i32 26, i32* %4
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %26
26: ; preds = %23, %20
br label %32
27: ; preds = %11
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 27
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 26, i32* %4
br label %31
31: ; preds = %30, %27
br label %32
32: ; preds = %31, %26
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = mul nsw i32 %34, 26
%36 = mul nsw i32 %35, 26
%37 = sub nsw i32 %33, %36
%38 = load i32, i32* %4
%39 = mul nsw i32 %38, 26
%40 = sub nsw i32 %37, %39
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %32
store i32 26, i32* %5
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
br label %46
46: ; preds = %43, %32
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* %3
%51 = add nsw i32 64, %50
%52 = trunc i32 %51 to i8
%53 = call i32 @putchar(i8 signext %52)
br label %54
54: ; preds = %49, %46
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i32, i32* %4
%59 = add nsw i32 64, %58
%60 = trunc i32 %59 to i8
%61 = call i32 @putchar(i8 signext %60)
br label %62
62: ; preds = %57, %54
%63 = load i32, i32* %5
%64 = add nsw i32 64, %63
%65 = trunc i32 %64 to i8
%66 = call i32 @putchar(i8 signext %65)
%67 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @printExcelColumnName(i32 %0) {
%2 = sdiv i32 %0, 676
%3 = icmp slt i32 %2, 26
%4 = select i1 %3, i32 %2, i32 26
%5 = mul nsw i32 %4, -676
%6 = add i32 %5, %0
%7 = add i32 %6, 25
%8 = icmp ult i32 %7, 51
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = icmp eq i32 %4, 0
%11 = add nsw i32 %4, -1
%12 = select i1 %10, i32 0, i32 %11
%13 = select i1 %10, i32 0, i32 26
%14 = mul i32 %12, -676
%15 = add i32 %14, %0
br label %21
16: ; preds = %1
%17 = sdiv i32 %6, 26
%18 = add i32 %6, -702
%19 = icmp ult i32 %18, 26
%20 = select i1 %19, i32 26, i32 %17
br label %21
21: ; preds = %9, %16
%22 = phi i32 [ %15, %9 ], [ %6, %16 ]
%23 = phi i32 [ %12, %9 ], [ %4, %16 ]
%24 = phi i32 [ %13, %9 ], [ %20, %16 ]
%25 = mul nsw i32 %24, -26
%26 = add i32 %22, %25
%27 = icmp eq i32 %26, 0
%28 = sext i1 %27 to i32
%29 = add nsw i32 %24, %28
%30 = icmp sgt i32 %23, 0
br i1 %30, label %31, label %35
31: ; preds = %21
%32 = trunc i32 %23 to i8
%33 = add nuw nsw i8 %32, 64
%34 = tail call i32 @putchar(i8 signext %33)
br label %35
35: ; preds = %31, %21
%36 = icmp sgt i32 %29, 0
br i1 %36, label %37, label %41
37: ; preds = %35
%38 = trunc i32 %29 to i8
%39 = add i8 %38, 64
%40 = tail call i32 @putchar(i8 signext %39)
br label %41
41: ; preds = %37, %35
%42 = trunc i32 %26 to i8
%43 = add i8 %42, 64
%44 = select i1 %27, i8 90, i8 %43
%45 = tail call i32 @putchar(i8 signext %44)
%46 = tail call i32 @putchar(i8 signext 10)
ret void
}