#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*/ NameFilter(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void ADos2Host(char *host, unsigned char *aDos) {
  char name[9];
  char ext[4];
  strncpy(name, (const char *)aDos, 8);
  name[8] = '\0';
  strncpy(ext, (const char *)aDos + 8, 3);
  ext[3] = '\0';
  NameFilter(name, name);
  NameFilter(ext, ext);
  if (!*name)
    strcpy(name, "out");
  strcpy(host, name);
  if (*ext) {
    strcat(host, ".");
    strcat(host, ext);
  }
}


x86 assembly (clang, -O0):
<ADos2Host>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x19(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x1a(%rbp)
lea    -0x19(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1050 <NameFilter@plt>
lea    -0x1d(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
call   1050 <NameFilter@plt>
cmpb   $0x0,-0x19(%rbp)
jne    11b4 <ADos2Host+0x74>
lea    -0x19(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x19(%rbp),%rsi
call   1040 <strcpy@plt>
cmpb   $0x0,-0x1d(%rbp)
je     11e8 <ADos2Host+0xa8>
mov    -0x8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
call   1060 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADos2Host>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xf(%rsp),%r15
mov    %r15,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x17(%rsp)
add    $0x8,%rbx
lea    0xb(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xe(%rsp)
mov    %r15,%rdi
mov    %r15,%rsi
call   1050 <NameFilter@plt>
mov    %r12,%rdi
mov    %r12,%rsi
call   1050 <NameFilter@plt>
cmpb   $0x0,0xf(%rsp)
jne    11b4 <ADos2Host+0x74>
lea    0xe56(%rip),%rsi
lea    0xf(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xf(%rsp),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
cmpb   $0x0,0xb(%rsp)
je     11e4 <ADos2Host+0xa4>
lea    0xe35(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
lea    0xb(%rsp),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"out\00"
@.str.1 = [2 x i8] c".\00"
define void @ADos2Host(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [9 x i8]
%6 = alloca [4 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = call i32 @strncpy(i8* %7, i8* %8, i32 8)
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 8
store i8 0, i8* %10
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 8
%14 = call i32 @strncpy(i8* %11, i8* %13, i32 3)
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 3
store i8 0, i8* %15
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%18 = call i32 @NameFilter(i8* %16, i8* %17)
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%21 = call i32 @NameFilter(i8* %19, i8* %20)
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %2
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %25, %2
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %28
%36 = load i8*, i8** %3
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = load i8*, i8** %3
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%40 = call i32 @strcat(i8* %38, i8* %39)
br label %41
41: ; preds = %35, %28
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"out\00"
@.str.1 = [2 x i8] c".\00"
define void @ADos2Host(i8* %0, i8* %1) {
%3 = alloca [9 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = call i32 @strncpy(i8* %5, i8* %1, i32 8)
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 8
store i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %1, i64 8
%10 = call i32 @strncpy(i8* %6, i8* %9, i32 3)
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 0, i8* %11
%12 = call i32 @NameFilter(i8* %5, i8* %5)
%13 = call i32 @NameFilter(i8* %6, i8* %6)
%14 = load i8, i8* %5
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = call i32 @strcpy(i8* %0, i8* %5)
%20 = load i8, i8* %6
%21 = icmp eq i8 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @strcat(i8* %0, i8* %6)
br label %25
25: ; preds = %22, %18
ret void
}