#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 strlen(char *);
void RFCNB_CvtPad_Name(char *name1, char *name2) {
  char c, c1, c2;
  int i, len;
  len = strlen(name1);
  for (i = 0; i < 16; i++) {
    if (i >= len) {
      c1 = 'C';
      c2 = 'A';
    } else {
      c = name1[i];
      c1 = (char)((int)c / 16 + (int)'A');
      c2 = (char)((int)c % 16 + (int)'A');
    }
    name2[i * 2] = c1;
    name2[i * 2 + 1] = c2;
  }
  name2[32] = 0;
}


x86 assembly (clang, -O0):
<RFCNB_CvtPad_Name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    11c1 <RFCNB_CvtPad_Name+0xb1>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1156 <RFCNB_CvtPad_Name+0x46>
movb   $0x43,-0x12(%rbp)
movb   $0x41,-0x13(%rbp)
jmp    118a <RFCNB_CvtPad_Name+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
add    $0x41,%eax
mov    %al,-0x12(%rbp)
movsbl -0x11(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%al
mov    %al,-0x13(%rbp)
mov    -0x12(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x13(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <RFCNB_CvtPad_Name+0x23>
mov    -0x10(%rbp),%rax
movb   $0x0,0x20(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RFCNB_CvtPad_Name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%rsi
xor    %ecx,%ecx
jmp    1161 <RFCNB_CvtPad_Name+0x51>
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rcx,1),%ebx
mov    %ebx,%edx
sar    $0x7,%dl
shr    $0x4,%dl
add    %bl,%dl
mov    %edx,%eax
sar    $0x4,%al
add    $0x41,%al
and    $0xf0,%dl
sub    %dl,%bl
add    $0x41,%bl
mov    %al,(%r15,%rcx,2)
mov    %bl,0x1(%r15,%rcx,2)
add    $0x1,%rcx
cmp    $0x10,%rcx
je     116c <RFCNB_CvtPad_Name+0x5c>
cmp    %rsi,%rcx
jl     1130 <RFCNB_CvtPad_Name+0x20>
mov    $0x43,%al
mov    $0x41,%bl
jmp    114e <RFCNB_CvtPad_Name+0x3e>
movb   $0x0,0x20(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @RFCNB_CvtPad_Name(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
br label %5
5: ; preds = %2, %15
%6 = phi i64 [ 0, %2 ], [ %22, %15 ]
%7 = icmp slt i64 %6, %4
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
%11 = sdiv i8 %10, 16
%12 = add nsw i8 %11, 65
%13 = srem i8 %10, 16
%14 = add nsw i8 %13, 65
br label %15
15: ; preds = %5, %8
%16 = phi i8 [ %14, %8 ], [ 65, %5 ]
%17 = phi i8 [ %12, %8 ], [ 67, %5 ]
%18 = shl nuw nsw i64 %6, 1
%19 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 %17, i8* %19
%20 = or i64 %18, 1
%21 = getelementptr inbounds i8, i8* %1, i64 %20
store i8 %16, i8* %21
%22 = add nuw nsw i64 %6, 1
%23 = icmp eq i64 %22, 16
br i1 %23, label %24, label %5
24: ; preds = %15
%25 = getelementptr inbounds i8, i8* %1, i64 32
store i8 0, i8* %25
ret void
}