#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tosFilename_getName(char *, char *);
int /*<<< orphan*/ tosFilename_normalize(char const *, char *, int);
int /*<<< orphan*/ tosFilename_setExtension(char *, char *);
int /*<<< orphan*/ tosFilename_setName(char *, char *);
void tosDll_convName(const char *pszFromPath, char *pszToPath, int n) {
  char dllName[80];
  tosFilename_normalize(pszFromPath, pszToPath, n);
  tosFilename_setExtension(pszToPath, "so");
  tosFilename_getName(pszToPath, dllName);
  if (strcmp(dllName, "libc") == 0) {
    tosFilename_setName(pszToPath, "libc");
  }
}


x86 assembly (clang, -O0):
<tosDll_convName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <tosFilename_normalize@plt>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <tosFilename_setExtension@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <tosFilename_getName@plt>
lea    -0x70(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <tosDll_convName+0x6a>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <tosFilename_setName@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tosDll_convName>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
call   1060 <tosFilename_normalize@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <tosFilename_setExtension@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <tosFilename_getName@plt>
lea    0xe80(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    119f <tosDll_convName+0x4f>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <tosFilename_setName@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"so\00"
@.str.1 = [5 x i8] c"libc\00"
define void @tosDll_convName(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [80 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @tosFilename_normalize(i8* %8, i8* %9, i32 %10)
%12 = load i8*, i8** %5
%13 = call i32 @tosFilename_setExtension(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%16 = call i32 @tosFilename_getName(i8* %14, i8* %15)
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = call i32 @tosFilename_setName(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %3
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"so\00"
@.str.1 = [5 x i8] c"libc\00"
define void @tosDll_convName(i8* %0, i8* %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @tosFilename_normalize(i8* %0, i8* %1, i32 %2)
%7 = tail call i32 @tosFilename_setExtension(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @tosFilename_getName(i8* %1, i8* %5)
%9 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @tosFilename_setName(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
ret void
}