#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 *strchr(char *, char);
char *strdup(char const *);
char *setup_label(const char *command) {
  char *label;
  label = strdup(command);
  label = strchr(label, '#') ? label + 1 : (char *)label;
  {
    char *iter = label;
    while ((iter = strchr(iter, '_')))
      iter[0] = ' ';
  }
  return label;
}


x86 assembly (clang, -O0):
<setup_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1162 <setup_label+0x42>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116a <setup_label+0x4a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x5f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a2 <setup_label+0x82>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
jmp    117a <setup_label+0x5a>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_label>:
push   %rbx
call   1040 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
cmp    $0x1,%rax
sbb    $0xffffffffffffffff,%rbx
mov    %rbx,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x5f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1167 <setup_label+0x47>
movb   $0x20,(%rax)
mov    %rax,%rdi
jmp    1150 <setup_label+0x30>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @setup_label(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i8 signext 35)
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
br label %15
13: ; preds = %1
%14 = load i8*, i8** %3
br label %15
15: ; preds = %13, %10
%16 = phi i8* [ %12, %10 ], [ %14, %13 ]
store i8* %16, i8** %3
%17 = load i8*, i8** %3
store i8* %17, i8** %4
br label %18
18: ; preds = %22, %15
%19 = load i8*, i8** %4
%20 = call i8* @strchr(i8* %19, i8 signext 95)
store i8* %20, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 32, i8* %24
br label %18
25: ; preds = %18
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
define i8* @setup_label(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = tail call i8* @strchr(i8* dereferenceable(1) %2, i8 signext 35)
%4 = icmp ne i8* %3, null
%5 = zext i1 %4 to i64
%6 = getelementptr i8, i8* %2, i64 %5
%7 = tail call i8* @strchr(i8* dereferenceable(1) %6, i8 signext 95)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1, %9
%10 = phi i8* [ %11, %9 ], [ %7, %1 ]
store i8 32, i8* %10
%11 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 95)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %9
13: ; preds = %9, %1
ret i8* %6
}