#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*/ memcpy(char *, unsigned char *, int);
int /*<<< orphan*/ memset(char *, char, int);
void fatshortnametostring(char dst[13], unsigned char src[11]) {
  char *scan, *dot;
  memset(dst, '\0', 13);
  memcpy(dst, src, 8);
  dot = dst + 8;
  for (scan = dst + 7; scan >= dst && *scan == ' '; scan--)
    dot--;
  if (src[8] == ' ')
    *dot = '\0';
  else {
    *dot++ = '.';
    memcpy(dot, src + 8, 3);
    dot[3] = '\0';
    for (scan = dot + 2; scan >= dot && *scan == ' '; scan--)
      *scan = '\0';
  }
}


x86 assembly (clang, -O0):
<fatshortnametostring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     118d <fatshortnametostring+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119d <fatshortnametostring+0x7d>
jmp    11ba <fatshortnametostring+0x9a>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    116a <fatshortnametostring+0x4a>
mov    -0x10(%rbp),%rax
movzbl 0x8(%rax),%eax
cmp    $0x20,%eax
jne    11d7 <fatshortnametostring+0xb7>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1263 <fatshortnametostring+0x143>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2e,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x22(%rbp)
jb     1236 <fatshortnametostring+0x116>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1246 <fatshortnametostring+0x126>
jmp    125e <fatshortnametostring+0x13e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1213 <fatshortnametostring+0xf3>
jmp    1263 <fatshortnametostring+0x143>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fatshortnametostring>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %esi,%esi
mov    $0xd,%edx
call   1030 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
lea    0x7(%r15),%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,(%rbx)
jne    115e <fatshortnametostring+0x3e>
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbx
jae    1150 <fatshortnametostring+0x30>
add    $0x1,%rbx
cmpb   $0x20,0x8(%r14)
jne    1172 <fatshortnametostring+0x52>
mov    %rbx,%r15
movb   $0x0,(%r15)
jmp    11ab <fatshortnametostring+0x8b>
add    $0x8,%r14
lea    0x1(%rbx),%r15
movb   $0x2e,(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
movb   $0x0,0x4(%rbx)
cmpb   $0x20,0x3(%rbx)
jne    11ab <fatshortnametostring+0x8b>
movb   $0x0,0x3(%rbx)
cmpb   $0x20,0x2(%rbx)
jne    11ab <fatshortnametostring+0x8b>
movb   $0x0,0x2(%rbx)
cmpb   $0x20,0x1(%rbx)
je     116c <fatshortnametostring+0x4c>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @fatshortnametostring(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @memset(i8* %7, i8 signext 0, i32 13)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 @memcpy(i8* %9, i8* %10, i32 8)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 8
store i8* %13, i8** %6
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 7
store i8* %15, i8** %5
br label %16
16: ; preds = %30, %2
%17 = load i8*, i8** %5
%18 = load i8*, i8** %3
%19 = icmp uge i8* %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br label %25
25: ; preds = %20, %16
%26 = phi i1 [ false, %16 ], [ %24, %20 ]
br i1 %26, label %27, label %33
27: ; preds = %25
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %6
br label %30
30: ; preds = %27
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %5
br label %16
33: ; preds = %25
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 8
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp eq i32 %37, 32
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = load i8*, i8** %6
store i8 0, i8* %40
br label %69
41: ; preds = %33
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %6
store i8 46, i8* %42
%44 = load i8*, i8** %6
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 8
%47 = call i32 @memcpy(i8* %44, i8* %46, i32 3)
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i64 3
store i8 0, i8* %49
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i64 2
store i8* %51, i8** %5
br label %52
52: ; preds = %65, %41
%53 = load i8*, i8** %5
%54 = load i8*, i8** %6
%55 = icmp uge i8* %53, %54
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8*, i8** %5
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 32
br label %61
61: ; preds = %56, %52
%62 = phi i1 [ false, %52 ], [ %60, %56 ]
br i1 %62, label %63, label %68
63: ; preds = %61
%64 = load i8*, i8** %5
store i8 0, i8* %64
br label %65
65: ; preds = %63
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i32 -1
store i8* %67, i8** %5
br label %52
68: ; preds = %61
br label %69
69: ; preds = %68, %39
ret void
}

LLVM IR (-O2):
define void @fatshortnametostring(i8* %0, i8* %1) {
%3 = tail call i32 @memset(i8* %0, i8 signext 0, i32 13)
%4 = tail call i32 @memcpy(i8* %0, i8* %1, i32 8)
%5 = getelementptr inbounds i8, i8* %0, i64 8
%6 = getelementptr inbounds i8, i8* %0, i64 7
br label %7
7: ; preds = %2, %12
%8 = phi i8* [ %5, %2 ], [ %13, %12 ]
%9 = phi i8* [ %6, %2 ], [ %14, %12 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %8, i64 -1
%14 = getelementptr inbounds i8, i8* %9, i64 -1
%15 = icmp ult i8* %14, %0
br i1 %15, label %16, label %7
16: ; preds = %12, %7
%17 = phi i8* [ %13, %12 ], [ %8, %7 ]
%18 = getelementptr inbounds i8, i8* %1, i64 8
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 32
br i1 %20, label %35, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %17, i64 1
store i8 46, i8* %17
%23 = tail call i32 @memcpy(i8* %22, i8* %18, i32 3)
%24 = getelementptr inbounds i8, i8* %17, i64 4
store i8 0, i8* %24
%25 = getelementptr inbounds i8, i8* %17, i64 3
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 32
br i1 %27, label %28, label %37
28: ; preds = %21
store i8 0, i8* %25
%29 = getelementptr inbounds i8, i8* %17, i64 2
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 32
br i1 %31, label %32, label %37
32: ; preds = %28
store i8 0, i8* %29
%33 = load i8, i8* %22
%34 = icmp eq i8 %33, 32
br i1 %34, label %35, label %37
35: ; preds = %32, %16
%36 = phi i8* [ %17, %16 ], [ %22, %32 ]
store i8 0, i8* %36
br label %37
37: ; preds = %35, %21, %28, %32
ret void
}