#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 *);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strrchr(char const *, char);
void ConstructFileName(const char *infile, char *outfile, char *ext) {
  char *end = strrchr(infile, '.');
  strcpy(outfile, infile);
  if (!end || strchr(end, '/') || strchr(end, '\\'))
    strcat(outfile, ext);
}


x86 assembly (clang, -O0):
<ConstructFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x20(%rbp)
je     11ae <ConstructFileName+0x6e>
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11ae <ConstructFileName+0x6e>
mov    -0x20(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11bb <ConstructFileName+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConstructFileName>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
test   %r12,%r12
je     1192 <ConstructFileName+0x52>
mov    %r12,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1192 <ConstructFileName+0x52>
mov    %r12,%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a8 <ConstructFileName+0x68>
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ConstructFileName(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** %4
%9 = call i8* @strrchr(i8* %8, i8 signext 46)
store i8* %9, i8** %7
%10 = load i8*, i8** %5
%11 = load i8*, i8** %4
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %23
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = call i64 @strchr(i8* %16, i8 signext 47)
%18 = icmp ne i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = call i64 @strchr(i8* %20, i8 signext 92)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19, %15, %3
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = call i32 @strcat(i8* %24, i8* %25)
br label %27
27: ; preds = %23, %19
ret void
}

LLVM IR (-O2):
define void @ConstructFileName(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = tail call i32 @strcpy(i8* %1, i8* %0)
%6 = icmp eq i8* %4, null
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = tail call i64 @strchr(i8* %4, i8 signext 47)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i64 @strchr(i8* %4, i8 signext 92)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10, %7, %3
%14 = tail call i32 @strcat(i8* %1, i8* %2)
br label %15
15: ; preds = %13, %10
ret void
}