#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 */
char *malloc(int);
int pow(int, int);
char *hash_to_prefix(int code) {
  char *str = malloc(sizeof(char) * (2 + 1));
  int div, rem = code, p;
  for (int i = 0; i < 2; i++) {
    p = pow(26, 2 - 1 - i);
    div = rem / p;
    rem = rem % p;
    str[i] = (char)(div + 97);
  }
  str[2] = '\0';
  return str;
}


x86 assembly (clang, -O0):
<hash_to_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x3,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    119a <hash_to_prefix+0x7a>
mov    $0x1,%esi
sub    -0x20(%rbp),%esi
mov    $0x1a,%edi
call   1040 <pow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x61,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1146 <hash_to_prefix+0x26>
mov    -0x10(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_to_prefix>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x3,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0x1a,%edi
mov    $0x1,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%ebp
add    $0x61,%al
mov    %al,(%rbx)
mov    $0x1a,%edi
xor    %esi,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
add    $0x61,%al
mov    %al,0x1(%rbx)
movb   $0x0,0x2(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8* @hash_to_prefix(i32 %0) {
%2 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%3 = tail call i32 @pow(i32 26, i32 1)
%4 = sdiv i32 %0, %3
%5 = srem i32 %0, %3
%6 = trunc i32 %4 to i8
%7 = add i8 %6, 97
store i8 %7, i8* %2
%8 = tail call i32 @pow(i32 26, i32 0)
%9 = sdiv i32 %5, %8
%10 = trunc i32 %9 to i8
%11 = add i8 %10, 97
%12 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %2, i64 2
store i8 0, i8* %13
ret i8* %2
}