#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*/ memmove(char *, char *, int);
char *strchr(char *, char);
int strlen(char *);
void clean_hdr(char *ln) {
  int spaces = 0;
  char *colon, *i;
  colon = strchr(ln, ':');
  if (colon == NULL)
    return;
  for (i = colon + 1; *i != '\0'; i++) {
    if (' ' == *i)
      spaces++;
    else
      break;
  }
  if (spaces > 1)
    memmove(colon + 2, i, strlen(ln) - (colon - ln) - 2);
}


x86 assembly (clang, -O0):
<clean_hdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1165 <clean_hdr+0x35>
jmp    1208 <clean_hdr+0xd8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11be <clean_hdr+0x8e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jne    11a3 <clean_hdr+0x73>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <clean_hdr+0x78>
jmp    11be <clean_hdr+0x8e>
jmp    11ad <clean_hdr+0x7d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1171 <clean_hdr+0x41>
cmpl   $0x1,-0xc(%rbp)
jle    1208 <clean_hdr+0xd8>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
cltq
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,%edx
call   1050 <memmove@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_hdr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a1 <clean_hdr+0x71>
mov    %rax,%r15
mov    $0xffffffff,%eax
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1160 <clean_hdr+0x30>
cmp    $0x2,%eax
jb     11a1 <clean_hdr+0x71>
mov    %r15,%r12
add    $0x2,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %r15d,%r14d
lea    (%r14,%rax,1),%edx
add    $0xfffffffe,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <memmove@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @clean_hdr(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%3 = icmp eq i8* %2, null
br i1 %3, label %23, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %10, %4 ], [ 0, %1 ]
%6 = phi i8* [ %7, %4 ], [ %2, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
%10 = add nuw nsw i32 %5, 1
br i1 %9, label %4, label %11
11: ; preds = %4
%12 = icmp ugt i32 %5, 1
br i1 %12, label %13, label %23
13: ; preds = %11
%14 = getelementptr inbounds i8, i8* %2, i64 2
%15 = tail call i32 @strlen(i8* %0)
%16 = ptrtoint i8* %2 to i64
%17 = ptrtoint i8* %0 to i64
%18 = sub i64 %17, %16
%19 = trunc i64 %18 to i32
%20 = add i32 %19, -2
%21 = add i32 %20, %15
%22 = tail call i32 @memmove(i8* %14, i8* %7, i32 %21)
br label %23
23: ; preds = %11, %13, %1
ret void
}