#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);
void s_convert_space_to_underscore(char *inStr) {
  char *ptr = inStr;
  if (ptr == NULL)
    return;
  for (ptr = strchr(inStr, ' '); ptr && *ptr; ptr = strchr(ptr, ' '))
    *ptr = '_';
}


x86 assembly (clang, -O0):
<s_convert_space_to_underscore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <s_convert_space_to_underscore+0x24>
jmp    1194 <s_convert_space_to_underscore+0x84>
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     1166 <s_convert_space_to_underscore+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1176 <s_convert_space_to_underscore+0x66>
jmp    1194 <s_convert_space_to_underscore+0x84>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
jmp    1146 <s_convert_space_to_underscore+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_convert_space_to_underscore>:
push   %rax
test   %rdi,%rdi
je     113c <s_convert_space_to_underscore+0x2c>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     113c <s_convert_space_to_underscore+0x2c>
cmpb   $0x0,(%rax)
je     113c <s_convert_space_to_underscore+0x2c>
movb   $0x5f,(%rax)
mov    %rax,%rdi
jmp    1120 <s_convert_space_to_underscore+0x10>
pop    %rax
ret

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

LLVM IR (-O2):
define void @s_convert_space_to_underscore(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* %0, i8 signext 32)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3, %10
%7 = phi i8* [ %11, %10 ], [ %4, %3 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
store i8 95, i8* %7
%11 = tail call i8* @strchr(i8* %7, i8 signext 32)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %6
13: ; preds = %10, %6, %3, %1
ret void
}