#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 *ccstrcat(char *, char);
char *ccstring();
int /*<<< orphan*/ ccstrinv(char *);
char *ccgenname(int n, char header) {
  char *ret = ccstring();
  int i;
  do {
    i = n % 10;
    n = n / 10;
    ret = ccstrcat(ret, (char)(i + '0'));
  } while (n);
  ret = ccstrcat(ret, header);
  ccstrinv(ret);
  return ret;
}


x86 assembly (clang, -O0):
<ccgenname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1040 <ccstring@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x30,%eax
movsbl %al,%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    114c <ccgenname+0x1c>
mov    -0x10(%rbp),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <ccstrcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ccstrinv@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccgenname>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <ccstring@plt>
movslq %ebx,%rbp
imul   $0x66666667,%rbp,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %ebp,%edx
sub    %ecx,%edx
add    $0x30,%dl
movsbl %dl,%esi
mov    %rax,%rdi
call   1030 <ccstrcat@plt>
add    $0x9,%ebp
cmp    $0x12,%ebp
ja     1140 <ccgenname+0x10>
movsbl %r14b,%esi
mov    %rax,%rdi
call   1030 <ccstrcat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <ccstrinv@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @ccgenname(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%7 = call i8* (...) @ccstring()
store i8* %7, i8** %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %3
%10 = srem i32 %9, 10
store i32 %10, i32* %6
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 10
store i32 %12, i32* %3
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 48
%16 = trunc i32 %15 to i8
%17 = call i8* @ccstrcat(i8* %13, i8 signext %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %8
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %8, label %21
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = load i8, i8* %4
%24 = call i8* @ccstrcat(i8* %22, i8 signext %23)
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = call i32 @ccstrinv(i8* %25)
%27 = load i8*, i8** %5
ret i8* %27
}

LLVM IR (-O2):
define i8* @ccgenname(i32 %0, i8 signext %1) {
%3 = tail call i8* (...) @ccstring()
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ %3, %2 ], [ %11, %4 ]
%6 = phi i32 [ %0, %2 ], [ %8, %4 ]
%7 = srem i32 %6, 10
%8 = sdiv i32 %6, 10
%9 = trunc i32 %7 to i8
%10 = add nsw i8 %9, 48
%11 = tail call i8* @ccstrcat(i8* %5, i8 signext %10)
%12 = add i32 %6, 9
%13 = icmp ult i32 %12, 19
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = tail call i8* @ccstrcat(i8* %11, i8 signext %1)
%16 = tail call i32 @ccstrinv(i8* %15)
ret i8* %15
}