char *cleanConfigValue(const char *configValue) {
  char *cleanValue, *temp;
  unsigned long i;
  cleanValue = (char *)calloc(strlen(configValue), sizeof(char *));
  strcpy(cleanValue, configValue);
  if (strlen(configValue)) {
    for (i = 0; i < strlen(cleanValue); i++) {
      if (strncmp(" ", &cleanValue[i], 1) != 0) {
        temp = (char *)calloc(((strlen(cleanValue)) - i), sizeof(char *));
        memmove(temp, cleanValue + (i), (strlen(cleanValue)) - i);
        free(cleanValue);
        cleanValue = (char *)calloc((strlen(temp)), sizeof(char *));
        strcpy(cleanValue, temp);
        free(temp);
        break;
      }
    }
    for (i = strlen(cleanValue) - 1; i > 0; i--) {
      if (strncmp(" ", &cleanValue[i], 1) != 0 &&
          strncmp("\n", &cleanValue[i], 1) != 0) {
        temp = (char *)calloc(i + 1, sizeof(char *));
        memcpy(temp, cleanValue, i + 1);
        free(cleanValue);
        cleanValue = (char *)calloc(i + 1, sizeof(char *));
        strcpy(cleanValue, temp);
        free(temp);
        break;
      }
    }
  }
  return cleanValue;
}


x86 assembly (clang, -O0):
<cleanConfigValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
je     1384 <cleanConfigValue+0x214>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    12a4 <cleanConfigValue+0x134>
mov    -0x10(%rbp),%rsi
add    -0x20(%rbp),%rsi
lea    0xe12(%rip),%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     128e <cleanConfigValue+0x11e>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
sub    -0x20(%rbp),%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
sub    -0x20(%rbp),%rdx
call   1090 <memmove@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    12a4 <cleanConfigValue+0x134>
jmp    1293 <cleanConfigValue+0x123>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11be <cleanConfigValue+0x4e>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    137f <cleanConfigValue+0x20f>
mov    -0x10(%rbp),%rsi
add    -0x20(%rbp),%rsi
lea    0xd31(%rip),%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     1369 <cleanConfigValue+0x1f9>
mov    -0x10(%rbp),%rsi
add    -0x20(%rbp),%rsi
lea    0xd11(%rip),%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     1369 <cleanConfigValue+0x1f9>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    $0x1,%rdx
call   1080 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    137f <cleanConfigValue+0x20f>
jmp    136e <cleanConfigValue+0x1fe>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    12b5 <cleanConfigValue+0x145>
jmp    1384 <cleanConfigValue+0x214>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanConfigValue>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    $0x8,%esi
mov    %rax,%rdi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
cmpb   $0x0,(%rbx)
je     1281 <cleanConfigValue+0x131>
mov    %r14,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
je     120c <cleanConfigValue+0xbc>
mov    %rax,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x20,(%r14,%rax,1)
jne    11b2 <cleanConfigValue+0x62>
add    $0x1,%rax
cmp    %rax,%rbx
jne    11a0 <cleanConfigValue+0x50>
jmp    120c <cleanConfigValue+0xbc>
mov    %r14,%r15
add    %rax,%r15
sub    %rax,%rbx
mov    $0x8,%esi
mov    %rbx,%rdi
call   1060 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <memcpy@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    $0x8,%esi
mov    %rax,%rdi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%rax
je     1281 <cleanConfigValue+0x131>
mov    %rax,%rbx
jmp    122a <cleanConfigValue+0xda>
nop
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
je     1281 <cleanConfigValue+0x131>
movzbl -0x1(%r14,%rbx,1),%eax
cmp    $0xa,%al
je     1220 <cleanConfigValue+0xd0>
cmp    $0x20,%al
je     1220 <cleanConfigValue+0xd0>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <memcpy@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
define i8* @cleanConfigValue(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = call i8* @calloc(i64 %7, i64 8)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = call i8* @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %2
%13 = call i64 @strlen(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %93
15: ; preds = %1
store i64 0, i64* %5
br label %16
16: ; preds = %50, %15
%17 = load i64, i64* %5
%18 = load i8*, i8** %3
%19 = call i64 @strlen(i8* %18)
%20 = icmp ult i64 %17, %19
br i1 %20, label %21, label %53
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = load i64, i64* %5
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %24, i64 1)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %49
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i64 @strlen(i8* %28)
%30 = load i64, i64* %5
%31 = sub i64 %29, %30
%32 = call i8* @calloc(i64 %31, i64 8)
store i8* %32, i8** %4
%33 = load i8*, i8** %4
%34 = load i8*, i8** %3
%35 = load i64, i64* %5
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8*, i8** %3
%38 = call i64 @strlen(i8* %37)
%39 = load i64, i64* %5
%40 = sub i64 %38, %39
%41 = load i8*, i8** %3
%42 = load i8*, i8** %4
%43 = call i64 @strlen(i8* %42)
%44 = call i8* @calloc(i64 %43, i64 8)
store i8* %44, i8** %3
%45 = load i8*, i8** %3
%46 = load i8*, i8** %4
%47 = call i8* @strcpy(i8* %45, i8* %46)
%48 = load i8*, i8** %4
br label %53
49: ; preds = %21
br label %50
50: ; preds = %49
%51 = load i64, i64* %5
%52 = add i64 %51, 1
store i64 %52, i64* %5
br label %16
53: ; preds = %27, %16
%54 = load i8*, i8** %3
%55 = call i64 @strlen(i8* %54)
%56 = sub i64 %55, 1
store i64 %56, i64* %5
br label %57
57: ; preds = %89, %53
%58 = load i64, i64* %5
%59 = icmp ugt i64 %58, 0
br i1 %59, label %60, label %92
60: ; preds = %57
%61 = load i8*, i8** %3
%62 = load i64, i64* %5
%63 = getelementptr inbounds i8, i8* %61, i64 %62
%64 = call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %63, i64 1)
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %88
66: ; preds = %60
%67 = load i8*, i8** %3
%68 = load i64, i64* %5
%69 = getelementptr inbounds i8, i8* %67, i64 %68
%70 = call i32 @strncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %69, i64 1)
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %88
72: ; preds = %66
%73 = load i64, i64* %5
%74 = add i64 %73, 1
%75 = call i8* @calloc(i64 %74, i64 8)
store i8* %75, i8** %4
%76 = load i8*, i8** %4
%77 = load i8*, i8** %3
%78 = load i64, i64* %5
%79 = add i64 %78, 1
%80 = load i8*, i8** %3
%81 = load i64, i64* %5
%82 = add i64 %81, 1
%83 = call i8* @calloc(i64 %82, i64 8)
store i8* %83, i8** %3
%84 = load i8*, i8** %3
%85 = load i8*, i8** %4
%86 = call i8* @strcpy(i8* %84, i8* %85)
%87 = load i8*, i8** %4
br label %92
88: ; preds = %66, %60
br label %89
89: ; preds = %88
%90 = load i64, i64* %5
%91 = add i64 %90, -1
store i64 %91, i64* %5
br label %57
92: ; preds = %72, %57
br label %93
93: ; preds = %92, %1
%94 = load i8*, i8** %3
ret i8* %94
}

LLVM IR (-O2):
define i8* @cleanConfigValue(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = tail call i8* @calloc(i64 %2, i64 8)
%4 = tail call i8* @strcpy(i8* dereferenceable(1) %3, i8* dereferenceable(1) %0)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %42, label %7
7: ; preds = %1
%8 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %7, %22
%11 = phi i64 [ %23, %22 ], [ 0, %7 ]
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %22, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %3, i64 %11
%17 = sub i64 %8, %11
%18 = tail call i8* @calloc(i64 %17, i64 8)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %18, i8* align 1 %16, i64 %17, i1 false)
tail call void @free(i8* %3)
%19 = tail call i64 @strlen(i8* dereferenceable(1) %18)
%20 = tail call i8* @calloc(i64 %19, i64 8)
%21 = tail call i8* @strcpy(i8* dereferenceable(1) %20, i8* dereferenceable(1) %18)
tail call void @free(i8* %18)
br label %25
22: ; preds = %10
%23 = add nuw i64 %11, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %10
25: ; preds = %22, %7, %15
%26 = phi i8* [ %20, %15 ], [ %3, %7 ], [ %3, %22 ]
%27 = tail call i64 @strlen(i8* dereferenceable(1) %26)
%28 = add i64 %27, -1
%29 = icmp eq i64 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %25, %39
%31 = phi i64 [ %40, %39 ], [ %28, %25 ]
%32 = phi i64 [ %31, %39 ], [ %27, %25 ]
%33 = getelementptr inbounds i8, i8* %26, i64 %31
%34 = load i8, i8* %33
switch i8 %34, label %35 [
i8 32, label %39
i8 10, label %39
]
35: ; preds = %30
%36 = tail call i8* @calloc(i64 %32, i64 8)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %36, i8* align 1 %26, i64 %32, i1 false)
tail call void @free(i8* %26)
%37 = tail call i8* @calloc(i64 %32, i64 8)
%38 = tail call i8* @strcpy(i8* dereferenceable(1) %37, i8* dereferenceable(1) %36)
tail call void @free(i8* %36)
br label %42
39: ; preds = %30, %30
%40 = add i64 %31, -1
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %30
42: ; preds = %39, %25, %35, %1
%43 = phi i8* [ %37, %35 ], [ %3, %1 ], [ %26, %25 ], [ %26, %39 ]
ret i8* %43
}