#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*/ strcat(char *, char const *);
int /*<<< orphan*/ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strrchr(char const *, char);
void MakeTmpName(char *outfile, const char *infile, const char *sectionName) {
  char *end = strrchr(infile, '.');
  if (end && !strchr(end, '/') && !strchr(end, '\\')) {
    strncpy(outfile, infile, end - infile);
    outfile[end - infile] = '\0';
  } else
    strcpy(outfile, infile);
  strcat(outfile, "-");
  strcat(outfile, sectionName);
  strcat(outfile, ".tmp");
}


x86 assembly (clang, -O0):
<MakeTmpName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e1 <MakeTmpName+0x91>
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%eax
jne    11e1 <MakeTmpName+0x91>
mov    -0x20(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
cmp    $0x0,%eax
jne    11e1 <MakeTmpName+0x91>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11ee <MakeTmpName+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1070 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeTmpName>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x2e,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     1198 <MakeTmpName+0x48>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %eax,%eax
jne    1198 <MakeTmpName+0x48>
mov    %r12,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %eax,%eax
je     11d7 <MakeTmpName+0x87>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <strcat@plt>
sub    %r15,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rbx,%r12,1)
jmp    11a3 <MakeTmpName+0x53>

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

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [5 x i8] c".tmp\00"
define void @MakeTmpName(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i32 @strchr(i8* %4, i8 signext 47)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = tail call i32 @strchr(i8* %4, i8 signext 92)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = ptrtoint i8* %4 to i64
%14 = ptrtoint i8* %1 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @strncpy(i8* %0, i8* %1, i32 %16)
%18 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 0, i8* %18
br label %21
19: ; preds = %9, %6, %3
%20 = tail call i32 @strcpy(i8* %0, i8* %1)
br label %21
21: ; preds = %19, %12
%22 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @strcat(i8* %0, i8* %2)
%24 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
ret void
}