#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 *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
char *removeUnderscores(char *str) {
  char *result = malloc(sizeof(char) * 256);
  char cToStr[2];
  cToStr[1] = '\0';
  int i = 0;
  while (str[i] != 0) {
    if (str[i] != '_') {
      cToStr[0] = str[i];
    } else {
      cToStr[0] = ' ';
    }
    strcat(result, cToStr);
    i++;
  }
  return result;
}


x86 assembly (clang, -O0):
<removeUnderscores>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a1 <removeUnderscores+0x81>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     1182 <removeUnderscores+0x62>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
jmp    1186 <removeUnderscores+0x66>
movb   $0x20,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <removeUnderscores+0x25>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeUnderscores>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
movb   $0x0,0xf(%rsp)
lea    0xe(%rsp),%r15
jmp    1165 <removeUnderscores+0x45>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x20,%al
mov    %al,0xe(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x5f,%al
je     1150 <removeUnderscores+0x30>
test   %al,%al
jne    1152 <removeUnderscores+0x32>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @removeUnderscores(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [2 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i8* @malloc(i32 256)
store i8* %6, i8** %3
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 0, i8* %7
store i32 0, i32* %5
br label %8
8: ; preds = %33, %1
%9 = load i8*, i8** %2
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, 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 %39
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 95
br i1 %23, label %24, label %31
24: ; preds = %16
%25 = load i8*, i8** %2
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 %29, i8* %30
br label %33
31: ; preds = %16
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 32, i8* %32
br label %33
33: ; preds = %31, %24
%34 = load i8*, i8** %3
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%36 = call i32 @strcat(i8* %34, i8* %35)
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %8
39: ; preds = %8
%40 = load i8*, i8** %3
ret i8* %40
}

LLVM IR (-O2):
define i8* @removeUnderscores(i8* nocapture %0) {
%2 = alloca [2 x i8]
%3 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 0, i8* %5
br label %6
6: ; preds = %11, %1
%7 = phi i64 [ %14, %11 ], [ 0, %1 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %11 [
i8 0, label %15
i8 95, label %10
]
10: ; preds = %6
br label %11
11: ; preds = %6, %10
%12 = phi i8 [ 32, %10 ], [ %9, %6 ]
store i8 %12, i8* %4
%13 = call i32 @strcat(i8* %3, i8* %4)
%14 = add nuw i64 %7, 1
br label %6
15: ; preds = %6
ret i8* %3
}