#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*/ strncpy(char *, char *, int);
void fat_expand_name(char *name, char *_ext, char *buf) {
  char *p;
  char ext[4];
  strncpy(buf, name, 8);
  strncpy(ext, _ext, 3);
  buf[8] = 0;
  ext[3] = 0;
  p = buf;
  while ((*p != 0) && (*p != ' '))
    p++;
  if ((*ext != 0) && (*ext != ' ')) {
    char *e = ext;
    *p++ = '.';
    while ((*e != 0) && (*e != ' ')) {
      *p++ = *e++;
    }
  }
  *p = 0;
}


x86 assembly (clang, -O0):
<fat_expand_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x8(%rax)
movb   $0x0,-0x21(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     1181 <fat_expand_name+0x71>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1191 <fat_expand_name+0x81>
jmp    11a2 <fat_expand_name+0x92>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <fat_expand_name+0x4c>
movsbl -0x24(%rbp),%eax
cmp    $0x0,%eax
je     1237 <fat_expand_name+0x127>
movsbl -0x24(%rbp),%eax
cmp    $0x20,%eax
je     1237 <fat_expand_name+0x127>
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2e,(%rax)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x32(%rbp)
je     11fb <fat_expand_name+0xeb>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    120b <fat_expand_name+0xfb>
jmp    1232 <fat_expand_name+0x122>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11d6 <fat_expand_name+0xc6>
jmp    1237 <fat_expand_name+0x127>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fat_expand_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rdx,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
lea    0x4(%rsp),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x8(%rbx)
movb   $0x0,0x7(%rsp)
testb  $0xdf,(%rbx)
je     1159 <fat_expand_name+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
testb  $0xdf,(%rbx)
jne    1150 <fat_expand_name+0x40>
mov    0x4(%rsp),%al
test   $0xdf,%al
je     1183 <fat_expand_name+0x73>
movb   $0x2e,(%rbx)
mov    $0x1,%ecx
test   $0xdf,%al
je     1180 <fat_expand_name+0x70>
nopl   (%rax)
mov    %al,(%rbx,%rcx,1)
movzbl 0x4(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   $0xdf,%al
jne    1170 <fat_expand_name+0x60>
add    %rcx,%rbx
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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