#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*/ reverse(char *);
char *maketail(int mode) {
  static char out[10];
  static int next = 0;
  int count = next;
  char *tmp = out;
  char base = (mode == 26) ? 'A' : '0';
  do {
    *tmp = (count % mode);
    count /= mode;
    if (mode == 16 && (*tmp >= 10))
      *tmp += 'A' - 10;
    else
      *tmp += base;
    tmp++;
  } while (count);
  *tmp = '\0';
  next++;
  reverse(out);
  return out;
}


x86 assembly (clang, -O0):
<maketail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2f17(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0x2f01(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x30,%eax
mov    $0x41,%ecx
cmp    $0x1a,%edx
cmove  %ecx,%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x10,-0x4(%rbp)
jne    118b <maketail+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jl     118b <maketail+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
add    $0x37,%ecx
mov    %cl,(%rax)
jmp    119a <maketail+0x8a>
movsbl -0x11(%rbp),%edx
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
add    %edx,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1145 <maketail+0x35>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2e7b(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e72(%rip)
lea    0x2e5f(%rip),%rdi
call   1030 <reverse@plt>
lea    0x2e53(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maketail>:
push   %rbx
mov    0x2f20(%rip),%r8d
cmp    $0x1a,%edi
mov    $0x41,%eax
mov    $0x30,%ecx
cmove  %eax,%ecx
lea    0x2efd(%rip),%rsi
movzbl %cl,%ecx
mov    %r8d,%eax
jmp    1152 <maketail+0x42>
nopw   0x0(%rax,%rax,1)
cmp    $0x10,%edi
cmovne %ecx,%ebx
add    %dl,%bl
mov    %bl,(%rsi)
add    $0x1,%rsi
test   %eax,%eax
je     1163 <maketail+0x53>
cltd
idiv   %edi
mov    $0x37,%ebx
cmp    $0xa,%dl
jge    1140 <maketail+0x30>
mov    %ecx,%ebx
jmp    1140 <maketail+0x30>
movb   $0x0,(%rsi)
add    $0x1,%r8d
mov    %r8d,0x2ec7(%rip)
lea    0x2eb4(%rip),%rbx
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@maketail.out = internal global [10 x i8] zeroinitializer
@maketail.next = internal global i32 0
define i8* @maketail(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
store i32 %0, i32* %2
%6 = load i32, i32* @maketail.next
store i32 %6, i32* %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0), i8** %4
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 26
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 65, i32 48
%11 = trunc i32 %10 to i8
store i8 %11, i8* %5
br label %12
12: ; preds = %45, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = srem i32 %13, %14
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %4
store i8 %16, i8* %17
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = sdiv i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 16
br i1 %22, label %23, label %34
23: ; preds = %12
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sge i32 %26, 10
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = add nsw i32 %31, 55
%33 = trunc i32 %32 to i8
store i8 %33, i8* %29
br label %42
34: ; preds = %23, %12
%35 = load i8, i8* %5
%36 = sext i8 %35 to i32
%37 = load i8*, i8** %4
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = add nsw i32 %39, %36
%41 = trunc i32 %40 to i8
store i8 %41, i8* %37
br label %42
42: ; preds = %34, %28
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
br label %45
45: ; preds = %42
%46 = load i32, i32* %3
%47 = icmp ne i32 %46, 0
br i1 %47, label %12, label %48
48: ; preds = %45
%49 = load i8*, i8** %4
store i8 0, i8* %49
%50 = load i32, i32* @maketail.next
%51 = add nsw i32 %50, 1
store i32 %51, i32* @maketail.next
%52 = call i32 @reverse(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0))
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0)
}

LLVM IR (-O2):
@maketail.out = internal global [10 x i8] zeroinitializer
@maketail.next = internal unnamed_addr global i32 0
define i8* @maketail(i32 %0) {
%2 = load i32, i32* @maketail.next
%3 = icmp eq i32 %0, 26
%4 = icmp eq i32 %0, 16
%5 = select i1 %3, i8 65, i8 48
br label %6
6: ; preds = %6, %1
%7 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0), %1 ], [ %16, %6 ]
%8 = phi i32 [ %2, %1 ], [ %11, %6 ]
%9 = srem i32 %8, %0
%10 = trunc i32 %9 to i8
%11 = sdiv i32 %8, %0
%12 = icmp sgt i8 %10, 9
%13 = select i1 %4, i1 %12, i1 false
%14 = select i1 %13, i8 55, i8 %5
%15 = add i8 %14, %10
store i8 %15, i8* %7
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = icmp eq i32 %11, 0
br i1 %17, label %18, label %6
18: ; preds = %6
store i8 0, i8* %16
%19 = add nsw i32 %2, 1
store i32 %19, i32* @maketail.next
%20 = tail call i32 @reverse(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0))
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @maketail.out, i64 0, i64 0)
}