#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 *, char *, int);
int /*<<< orphan*/ memset(char *, int, int);
int strlen(char *);
char *strrchr(char *, char);
void makeName(char *name, char *buf) {
  if (name == NULL)
    return;
  memset(buf, 0x20, 9);
  char *ptr = strrchr(name, '.');
  if (ptr) {
    memcpy(buf, name, ((ptr - name) > 8) ? 8 : (ptr - name));
    ptr++;
    if (*ptr)
      buf[8] = *ptr;
  } else {
    memcpy(buf, name, (strlen(name) > 8) ? 8 : strlen(name));
  }
}


x86 assembly (clang, -O0):
<makeName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1160 <makeName+0x20>
jmp    125b <makeName+0x11b>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1210 <makeName+0xd0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x8,%rax
jle    11c3 <makeName+0x83>
mov    $0x8,%eax
mov    %rax,-0x30(%rbp)
jmp    11d2 <makeName+0x92>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     120b <makeName+0xcb>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
jmp    125b <makeName+0x11b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
jle    123f <makeName+0xff>
mov    $0x8,%eax
mov    %eax,-0x44(%rbp)
jmp    124b <makeName+0x10b>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
call   1060 <memcpy@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeName>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     119d <makeName+0x5d>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x20,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11a3 <makeName+0x63>
mov    %rax,%r15
sub    %rbx,%rax
cmp    $0x8,%rax
mov    $0x8,%edx
cmovl  %eax,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
mov    0x1(%r15),%al
test   %al,%al
je     119d <makeName+0x5d>
mov    %al,0x8(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x8,%edx
cmp    $0x8,%eax
jg     11bf <makeName+0x7f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <memcpy@plt>

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

LLVM IR (-O2):
define void @makeName(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %29, label %4
4: ; preds = %2
%5 = tail call i32 @memset(i8* %1, i32 32, i32 9)
%6 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%7 = icmp eq i8* %6, null
br i1 %7, label %21, label %8
8: ; preds = %4
%9 = ptrtoint i8* %6 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = icmp slt i64 %11, 8
%13 = select i1 %12, i64 %11, i64 8
%14 = trunc i64 %13 to i32
%15 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %14)
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %8
%20 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %17, i8* %20
br label %29
21: ; preds = %4
%22 = tail call i32 @strlen(i8* %0)
%23 = icmp sgt i32 %22, 8
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @strlen(i8* %0)
br label %26
26: ; preds = %21, %24
%27 = phi i32 [ %25, %24 ], [ 8, %21 ]
%28 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %27)
br label %29
29: ; preds = %26, %19, %8, %2
ret void
}