#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 */
scalar_t__ malloc(int);
char *convertToTitle(int n) {
  int t = n;
  int c = 0;
  while (t > 0) {
    t = (--t) / 26;
    c++;
  }
  char *res = (char *)malloc((c + 1) * sizeof(char));
  res[c] = 0;
  while (n > 0) {
    res[--c] = 'A' + (--n) % 26;
    n /= 26;
  }
  return res;
}


x86 assembly (clang, -O0):
<convertToTitle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1154 <convertToTitle+0x44>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <convertToTitle+0x18>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x4(%rbp)
jle    11bb <convertToTitle+0xab>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1177 <convertToTitle+0x67>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertToTitle>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1192 <convertToTitle+0x82>
mov    %edi,%r14d
mov    $0xffffffffffffffff,%rbx
mov    %edi,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%eax
imul   $0x4ec4ec4f,%rax,%rcx
shr    $0x23,%rcx
add    $0x1,%rbx
cmp    $0x19,%eax
mov    %ecx,%eax
ja     1130 <convertToTitle+0x20>
lea    0x2(%rbx),%edi
call   1030 <malloc@plt>
movb   $0x0,0x1(%rax,%rbx,1)
test   %r14d,%r14d
jle    119f <convertToTitle+0x8f>
add    %rax,%rbx
xchg   %ax,%ax
add    $0xffffffff,%r14d
imul   $0x4ec4ec4f,%r14,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
mov    %r14d,%esi
sub    %edx,%esi
add    $0x41,%sil
mov    %sil,(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    $0x19,%r14d
mov    %ecx,%r14d
ja     1160 <convertToTitle+0x50>
jmp    119f <convertToTitle+0x8f>
mov    $0x1,%edi
call   1030 <malloc@plt>
movb   $0x0,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @convertToTitle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
%6 = load i32, i32* %2
store i32 %6, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %10, %1
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = sdiv i32 %12, 26
store i32 %13, i32* %3
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %7
16: ; preds = %7
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %5
%24 = load i8*, i8** %5
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %31, %16
%29 = load i32, i32* %2
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %28
%32 = load i32, i32* %2
%33 = add nsw i32 %32, -1
store i32 %33, i32* %2
%34 = srem i32 %33, 26
%35 = add nsw i32 65, %34
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %5
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 %36, i8* %41
%42 = load i32, i32* %2
%43 = sdiv i32 %42, 26
store i32 %43, i32* %2
br label %28
44: ; preds = %28
%45 = load i8*, i8** %5
ret i8* %45
}

LLVM IR (-O2):
define i8* @convertToTitle(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = tail call i64 @malloc(i32 1)
%5 = inttoptr i64 %4 to i8*
store i8 0, i8* %5
br label %32
6: ; preds = %1, %6
%7 = phi i32 [ %11, %6 ], [ 0, %1 ]
%8 = phi i32 [ %10, %6 ], [ %0, %1 ]
%9 = add nsw i32 %8, -1
%10 = udiv i32 %9, 26
%11 = add nuw nsw i32 %7, 1
%12 = icmp ult i32 %9, 26
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = add nuw nsw i32 %7, 2
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = zext i32 %11 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8 0, i8* %18
br i1 %2, label %19, label %32
19: ; preds = %13
%20 = zext i32 %11 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ %20, %19 ], [ %28, %21 ]
%23 = phi i32 [ %0, %19 ], [ %30, %21 ]
%24 = add nsw i32 %23, -1
%25 = urem i32 %24, 26
%26 = trunc i32 %25 to i8
%27 = add nuw nsw i8 %26, 65
%28 = add i64 %22, -1
%29 = getelementptr inbounds i8, i8* %16, i64 %28
store i8 %27, i8* %29
%30 = udiv i32 %24, 26
%31 = icmp ult i32 %24, 26
br i1 %31, label %32, label %21
32: ; preds = %21, %3, %13
%33 = phi i8* [ %5, %3 ], [ %16, %13 ], [ %16, %21 ]
ret i8* %33
}