#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void remove_config_note(char *str) {
  int index = 0;
  char *tmp;
  tmp = (char *)malloc(strlen(str) * sizeof(char));
  while (str[index] != '\0') {
    if (str[index] == '#')
      break;
    tmp[index] = str[index];
    index++;
  }
  strcpy(str, tmp);
  free(tmp);
}


x86 assembly (clang, -O0):
<remove_config_note>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11c0 <remove_config_note+0x80>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
jne    119c <remove_config_note+0x5c>
jmp    11c0 <remove_config_note+0x80>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <remove_config_note+0x2d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_config_note>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rax,1),%ecx
test   %cl,%cl
je     1177 <remove_config_note+0x37>
cmp    $0x23,%cl
je     1177 <remove_config_note+0x37>
mov    %cl,(%rbx,%rax,1)
add    $0x1,%rax
jmp    1160 <remove_config_note+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @remove_config_note(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 1
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
br label %12
12: ; preds = %29, %1
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %41
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 35
br i1 %27, label %28, label %29
28: ; preds = %20
br label %41
29: ; preds = %20
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i8*, i8** %4
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %12
41: ; preds = %28, %12
%42 = load i8*, i8** %2
%43 = load i8*, i8** %4
%44 = call i32 @strcpy(i8* %42, i8* %43)
%45 = load i8*, i8** %4
%46 = call i32 @free(i8* %45)
ret void
}

LLVM IR (-O2):
define void @remove_config_note(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i8*
br label %5
5: ; preds = %9, %1
%6 = phi i64 [ %11, %9 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %12
i8 35, label %12
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %4, i64 %6
store i8 %8, i8* %10
%11 = add nuw i64 %6, 1
br label %5
12: ; preds = %5, %5
%13 = tail call i32 @strcpy(i8* %0, i8* %4)
%14 = tail call i32 @free(i8* %4)
ret void
}