#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ cleanfilename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int rename(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ ttfnamefixup(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ unlink(char *);
void ttfnameset(FILE *ttf, char *curname, char *patheticattempt) {
  char buffer[1024];
  if (!ttfnamefixup(ttf, buffer))
    strcpy(buffer, patheticattempt);
  if (!cleanfilename(buffer))
    unlink(curname);
  else if (rename(curname, buffer) == -1) {
    fprintf(stderr, "Could not create %s\n", buffer);
    unlink(curname);
  }
}


x86 assembly (clang, -O0):
<ttfnameset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1050 <ttfnamefixup@plt>
cmp    $0x0,%eax
jne    11a0 <ttfnameset+0x40>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x420(%rbp),%rdi
call   1060 <cleanfilename@plt>
cmp    $0x0,%eax
jne    11c3 <ttfnameset+0x63>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
jmp    1206 <ttfnameset+0xa6>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1080 <rename@plt>
cmp    $0xffffffff,%eax
jne    1201 <ttfnameset+0xa1>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    0xe0d(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
jmp    1206 <ttfnameset+0xa6>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ttfnameset>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rsp,%rsi
call   1050 <ttfnamefixup@plt>
test   %eax,%eax
jne    1187 <ttfnameset+0x27>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rsp,%rdi
call   1060 <cleanfilename@plt>
test   %eax,%eax
je     11bb <ttfnameset+0x5b>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1080 <rename@plt>
cmp    $0xffffffff,%eax
jne    11c3 <ttfnameset+0x63>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    %rsp,%rdx
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Could not create %s\0A\00"
define void @ttfnameset(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32*, i32** %4
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%10 = call i32 @ttfnamefixup(i32* %8, i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @strcpy(i8* %13, i8* %14)
br label %16
16: ; preds = %12, %3
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = call i32 @cleanfilename(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = call i32 @unlink(i8* %21)
br label %35
23: ; preds = %16
%24 = load i8*, i8** %5
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%26 = call i32 @rename(i8* %24, i8* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %5
%33 = call i32 @unlink(i8* %32)
br label %34
34: ; preds = %28, %23
br label %35
35: ; preds = %34, %20
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Could not create %s\0A\00"
define void @ttfnameset(i32* %0, i8* nocapture %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @ttfnamefixup(i32* %0, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @strcpy(i8* %5, i8* %2)
br label %10
10: ; preds = %8, %3
%11 = call i32 @cleanfilename(i8* %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = call i32 @rename(i8* %1, i8* %5)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %19
19: ; preds = %10, %16
%20 = call i32 @unlink(i8* %1)
br label %21
21: ; preds = %19, %13
ret void
}