#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 */
char *cloneString(int /*<<< orphan*/);
int /*<<< orphan*/ eraseTrailingSpaces(char *);
int /*<<< orphan*/ memSwapChar(char *, int /*<<< orphan*/, char, char);
int /*<<< orphan*/ skipLeadingSpaces(char *);
int /*<<< orphan*/ strlen(char *);
char *textOutSanitizeHttpFileName(char *fileName) {
  char *sanitized = cloneString(skipLeadingSpaces(fileName));
  eraseTrailingSpaces(sanitized);
  (void)memSwapChar((sanitized), strlen(sanitized), ('/'), ('_'));
  (void)memSwapChar((sanitized), strlen(sanitized), (','), ('.'));
  return sanitized;
}


x86 assembly (clang, -O0):
<textOutSanitizeHttpFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <skipLeadingSpaces@plt>
mov    %eax,%edi
call   1050 <cloneString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <eraseTrailingSpaces@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
mov    $0x2f,%edx
mov    $0x5f,%ecx
call   1070 <memSwapChar@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
mov    $0x2c,%edx
mov    $0x2e,%ecx
call   1070 <memSwapChar@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textOutSanitizeHttpFileName>:
push   %rbx
call   1040 <skipLeadingSpaces@plt>
mov    %eax,%edi
call   1050 <cloneString@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <eraseTrailingSpaces@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2f,%edx
mov    $0x5f,%ecx
call   1070 <memSwapChar@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2c,%edx
mov    $0x2e,%ecx
call   1070 <memSwapChar@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @textOutSanitizeHttpFileName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @skipLeadingSpaces(i8* %4)
%6 = call i8* @cloneString(i32 %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @eraseTrailingSpaces(i8* %7)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @memSwapChar(i8* %9, i32 %11, i8 signext 47, i8 signext 95)
%13 = load i8*, i8** %3
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @memSwapChar(i8* %13, i32 %15, i8 signext 44, i8 signext 46)
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
define i8* @textOutSanitizeHttpFileName(i8* %0) {
%2 = tail call i32 @skipLeadingSpaces(i8* %0)
%3 = tail call i8* @cloneString(i32 %2)
%4 = tail call i32 @eraseTrailingSpaces(i8* %3)
%5 = tail call i32 @strlen(i8* %3)
%6 = tail call i32 @memSwapChar(i8* %3, i32 %5, i8 signext 47, i8 signext 95)
%7 = tail call i32 @strlen(i8* %3)
%8 = tail call i32 @memSwapChar(i8* %3, i32 %7, i8 signext 44, i8 signext 46)
ret i8* %3
}