#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*/ sprintf(char *, char *, char, ...);
char *DeviceNameGet(const int index, char *szBuf) {
  if (index < 26) {
    sprintf(szBuf, "sd%c", 'a' + index % 26);
  } else if (index < (26 + 1) * 26) {
    sprintf(szBuf, "sd%c%c", 'a' + index / 26 - 1, 'a' + index % 26);
  } else {
    const unsigned int m1 = (index / 26 - 1) / 26 - 1;
    const unsigned int m2 = (index / 26 - 1) % 26;
    const unsigned int m3 = index % 26;
    sprintf(szBuf, "sd%c%c%c", 'a' + m1, 'a' + m2, 'a' + m3);
  }
  return szBuf;
}


x86 assembly (clang, -O0):
<DeviceNameGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1a,-0x4(%rbp)
jge    1153 <DeviceNameGet+0x43>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%al
lea    0xebc(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1212 <DeviceNameGet+0x102>
cmpl   $0x2be,-0x4(%rbp)
jge    11a1 <DeviceNameGet+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%eax
sub    $0x1,%eax
mov    %al,-0x1d(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x1d(%rbp),%al
mov    %edx,%ecx
add    $0x61,%ecx
lea    0xe73(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    120d <DeviceNameGet+0xfd>
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x61,%eax
mov    -0x18(%rbp),%ecx
add    $0x61,%ecx
mov    -0x1c(%rbp),%r8d
add    $0x61,%r8d
lea    0xe09(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1212 <DeviceNameGet+0x102>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DeviceNameGet>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x19,%edi
jg     1158 <DeviceNameGet+0x48>
movslq %edi,%rax
imul   $0x4ec4ec4f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%edi
add    $0x61,%dil
movsbl %dil,%edx
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11eb <DeviceNameGet+0xdb>
cmp    $0x2bd,%edi
ja     1198 <DeviceNameGet+0x88>
movzwl %di,%eax
imul   $0x4ec5,%eax,%eax
shr    $0x13,%eax
lea    0x60(%rax),%edx
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
neg    %ecx
lea    (%rdi,%rcx,1),%eax
add    $0x61,%eax
movzwl %ax,%ecx
movsbl %dl,%edx
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11eb <DeviceNameGet+0xdb>
mov    %edi,%eax
imul   $0x4ec4ec4f,%rax,%rax
shr    $0x23,%rax
lea    -0x1(%rax),%ecx
imul   $0x4ec4ec4f,%rcx,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %edx,%ecx
lea    (%rax,%rax,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %eax,%esi
add    $0x60,%dl
neg    %ecx
add    %eax,%ecx
add    $0x60,%ecx
neg    %esi
lea    (%rdi,%rsi,1),%r8d
add    $0x61,%r8d
movsbl %dl,%edx
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"sd%c\00"
@.str.1 = [7 x i8] c"sd%c%c\00"
@.str.2 = [9 x i8] c"sd%c%c%c\00"
define i8* @DeviceNameGet(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 26
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i32, i32* %3
%13 = srem i32 %12, 26
%14 = add nsw i32 97, %13
%15 = trunc i32 %14 to i8
%16 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %15)
br label %53
17: ; preds = %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 702
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 26
%24 = add nsw i32 97, %23
%25 = sub nsw i32 %24, 1
%26 = trunc i32 %25 to i8
%27 = load i32, i32* %3
%28 = srem i32 %27, 26
%29 = add nsw i32 97, %28
%30 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %26, i32 %29)
br label %52
31: ; preds = %17
%32 = load i32, i32* %3
%33 = sdiv i32 %32, 26
%34 = sub nsw i32 %33, 1
%35 = sdiv i32 %34, 26
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %5
%37 = load i32, i32* %3
%38 = sdiv i32 %37, 26
%39 = sub nsw i32 %38, 1
%40 = srem i32 %39, 26
store i32 %40, i32* %6
%41 = load i32, i32* %3
%42 = srem i32 %41, 26
store i32 %42, i32* %7
%43 = load i8*, i8** %4
%44 = load i32, i32* %5
%45 = add i32 97, %44
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %6
%48 = add i32 97, %47
%49 = load i32, i32* %7
%50 = add i32 97, %49
%51 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8 signext %46, i32 %48, i32 %50)
br label %52
52: ; preds = %31, %20
br label %53
53: ; preds = %52, %10
%54 = load i8*, i8** %4
ret i8* %54
}

LLVM IR (-O2):
@.str = [5 x i8] c"sd%c\00"
@.str.1 = [7 x i8] c"sd%c%c\00"
@.str.2 = [9 x i8] c"sd%c%c%c\00"
define i8* @DeviceNameGet(i32 %0, i8* returned writeonly %1) {
%3 = icmp slt i32 %0, 26
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = srem i32 %0, 26
%6 = trunc i32 %5 to i8
%7 = add nsw i8 %6, 97
%8 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %7)
br label %31
9: ; preds = %2
%10 = icmp ult i32 %0, 702
br i1 %10, label %11, label %20
11: ; preds = %9
%12 = trunc i32 %0 to i16
%13 = udiv i16 %12, 26
%14 = trunc i16 %13 to i8
%15 = add nuw nsw i8 %14, 96
%16 = urem i16 %12, 26
%17 = add nuw nsw i16 %16, 97
%18 = zext i16 %17 to i32
%19 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %15, i32 %18)
br label %31
20: ; preds = %9
%21 = udiv i32 %0, 26
%22 = add nsw i32 %21, -1
%23 = udiv i32 %22, 26
%24 = urem i32 %22, 26
%25 = urem i32 %0, 26
%26 = trunc i32 %23 to i8
%27 = add i8 %26, 96
%28 = add nuw nsw i32 %24, 97
%29 = add nuw nsw i32 %25, 97
%30 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8 signext %27, i32 %28, i32 %29)
br label %31
31: ; preds = %11, %20, %4
ret i8* %1
}