#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 *strstr(char *, char *);
void remove_trailing_colon_space(char *text) {
  int i = 0;
  char *sub = NULL;
  sub = strstr(text, ": \"");
  while (sub[i + 2] != 0) {
    sub[i] = sub[i + 2];
    i++;
  }
  sub[i] = 0;
}


x86 assembly (clang, -O0):
<remove_trailing_colon_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeca(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1182 <remove_trailing_colon_space+0x72>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%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    113f <remove_trailing_colon_space+0x2f>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_trailing_colon_space>:
push   %rax
lea    0xee8(%rip),%rsi
call   1030 <strstr@plt>
mov    0x2(%rax),%cl
test   %cl,%cl
je     1144 <remove_trailing_colon_space+0x34>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
mov    %cl,(%rax,%rdx,1)
movzbl 0x3(%rax,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1130 <remove_trailing_colon_space+0x20>
mov    %edx,%ecx
jmp    1146 <remove_trailing_colon_space+0x36>
xor    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
pop    %rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c": \22\00"
define void @remove_trailing_colon_space(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
store i8* null, i8** %4
%5 = load i8*, i8** %2
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
br label %7
7: ; preds = %16, %1
%8 = load i8*, i8** %4
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %7
%17 = load i8*, i8** %4
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
%30 = load i8*, i8** %4
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c": \22\00"
define void @remove_trailing_colon_space(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds i8, i8* %2, i64 2
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %10, %6 ], [ 0, %1 ]
%8 = phi i8 [ %13, %6 ], [ %4, %1 ]
%9 = getelementptr inbounds i8, i8* %2, i64 %7
store i8 %8, i8* %9
%10 = add nuw i64 %7, 1
%11 = add nuw nsw i64 %7, 3
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6
%16 = and i64 %10, 4294967295
br label %17
17: ; preds = %15, %1
%18 = phi i64 [ 0, %1 ], [ %16, %15 ]
%19 = getelementptr inbounds i8, i8* %2, i64 %18
store i8 0, i8* %19
ret void
}