#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*/ strncpy(char *, char const *, int);
void getfname(char *name, const char *tty) {
  int i;
  memcpy(name, "/tmp/vitetris-", 14);
  strncpy(name + 14, tty, 7);
  name[21] = '\0';
  for (i = 14; i < 20 && name[i]; i++)
    if (name[i] == '/')
      name[i] = '-';
}


x86 assembly (clang, -O0):
<getfname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0xe,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0xe,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x15(%rax)
movl   $0xe,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x14,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jge    118e <getfname+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119e <getfname+0x7e>
jmp    11d2 <getfname+0xb2>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11bf <getfname+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x2d,(%rax,%rcx,1)
jmp    11c4 <getfname+0xa4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <getfname+0x4a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getfname>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
mov    $0xe,%edx
call   1040 <memcpy@plt>
lea    0xe(%rbx),%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x15(%rbx)
mov    0xe(%rbx),%al
test   %al,%al
je     11a9 <getfname+0x89>
cmp    $0x2f,%al
jne    1163 <getfname+0x43>
movb   $0x2d,(%r14)
mov    0xf(%rbx),%al
test   %al,%al
je     11a9 <getfname+0x89>
cmp    $0x2f,%al
jne    1172 <getfname+0x52>
movb   $0x2d,0xf(%rbx)
mov    0x10(%rbx),%al
test   %al,%al
je     11a9 <getfname+0x89>
cmp    $0x2f,%al
jne    1181 <getfname+0x61>
movb   $0x2d,0x10(%rbx)
mov    0x11(%rbx),%al
test   %al,%al
je     11a9 <getfname+0x89>
cmp    $0x2f,%al
jne    1190 <getfname+0x70>
movb   $0x2d,0x11(%rbx)
mov    0x12(%rbx),%al
test   %al,%al
je     11a9 <getfname+0x89>
cmp    $0x2f,%al
jne    119f <getfname+0x7f>
movb   $0x2d,0x12(%rbx)
cmpb   $0x2f,0x13(%rbx)
jne    11a9 <getfname+0x89>
movb   $0x2d,0x13(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/tmp/vitetris-\00"
define void @getfname(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @memcpy(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 14
%10 = load i8*, i8** %4
%11 = call i32 @strncpy(i8* %9, i8* %10, i32 7)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 21
store i8 0, i8* %13
store i32 14, i32* %5
br label %14
14: ; preds = %41, %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 20
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %17, %14
%26 = phi i1 [ false, %14 ], [ %24, %17 ]
br i1 %26, label %27, label %44
27: ; preds = %25
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 47
br i1 %34, label %35, label %40
35: ; preds = %27
%36 = load i8*, i8** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 45, i8* %39
br label %40
40: ; preds = %35, %27
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %14
44: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"/tmp/vitetris-\00"
define void @getfname(i8* %0, i8* %1) {
%3 = tail call i32 @memcpy(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%4 = getelementptr inbounds i8, i8* %0, i64 14
%5 = tail call i32 @strncpy(i8* %4, i8* %1, i32 7)
%6 = getelementptr inbounds i8, i8* %0, i64 21
store i8 0, i8* %6
%7 = load i8, i8* %4
switch i8 %7, label %9 [
i8 0, label %30
i8 47, label %8
]
8: ; preds = %2
store i8 45, i8* %4
br label %9
9: ; preds = %2, %8
%10 = getelementptr inbounds i8, i8* %0, i64 15
%11 = load i8, i8* %10
switch i8 %11, label %13 [
i8 0, label %30
i8 47, label %12
]
12: ; preds = %9
store i8 45, i8* %10
br label %13
13: ; preds = %12, %9
%14 = getelementptr inbounds i8, i8* %0, i64 16
%15 = load i8, i8* %14
switch i8 %15, label %17 [
i8 0, label %30
i8 47, label %16
]
16: ; preds = %13
store i8 45, i8* %14
br label %17
17: ; preds = %16, %13
%18 = getelementptr inbounds i8, i8* %0, i64 17
%19 = load i8, i8* %18
switch i8 %19, label %21 [
i8 0, label %30
i8 47, label %20
]
20: ; preds = %17
store i8 45, i8* %18
br label %21
21: ; preds = %20, %17
%22 = getelementptr inbounds i8, i8* %0, i64 18
%23 = load i8, i8* %22
switch i8 %23, label %25 [
i8 0, label %30
i8 47, label %24
]
24: ; preds = %21
store i8 45, i8* %22
br label %25
25: ; preds = %24, %21
%26 = getelementptr inbounds i8, i8* %0, i64 19
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 47
br i1 %28, label %29, label %30
29: ; preds = %25
store i8 45, i8* %26
br label %30
30: ; preds = %25, %29, %21, %17, %13, %9, %2
ret void
}