#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strstr(char *, char *);
void cFileNameToCppFileName(char *fileName) {
  char *ptrstr;
  char bufstr[64];
  if (strstr(fileName, ".c"))
    strcat(fileName, "pp");
  ptrstr = strstr(fileName, "/c/");
  strcpy(bufstr, ptrstr + 3);
  *ptrstr = '\0';
  strcat(fileName, "/cpp/");
  strcat(fileName, bufstr);
}


x86 assembly (clang, -O0):
<cFileNameToCppFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     1166 <cFileNameToCppFileName+0x36>
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x3,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cFileNameToCppFileName>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r14
lea    0xebd(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     115c <cFileNameToCppFileName+0x2c>
lea    0xeaf(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
call   1050 <strstr@plt>
mov    %rax,%rbx
lea    0x3(%rax),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
movb   $0x0,(%rbx)
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c".c\00"
@.str.1 = [3 x i8] c"pp\00"
@.str.2 = [4 x i8] c"/c/\00"
@.str.3 = [6 x i8] c"/cpp/\00"
define void @cFileNameToCppFileName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [64 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %2
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %3
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 3
%17 = call i32 @strcpy(i8* %14, i8* %16)
%18 = load i8*, i8** %3
store i8 0, i8* %18
%19 = load i8*, i8** %2
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%21 = load i8*, i8** %2
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%23 = call i32 @strcat(i8* %21, i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c".c\00"
@.str.1 = [3 x i8] c"pp\00"
@.str.2 = [4 x i8] c"/c/\00"
@.str.3 = [6 x i8] c"/cpp/\00"
define void @cFileNameToCppFileName(i8* %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds i8, i8* %9, i64 3
%11 = call i32 @strcpy(i8* %3, i8* %10)
store i8 0, i8* %9
%12 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @strcat(i8* %0, i8* %3)
ret void
}