#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*/ StrSpaceToHyphen(char *);
int /*<<< orphan*/ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  const int INPUT_STR_SIZE = 50;
  char userStr[INPUT_STR_SIZE];
  printf("Enter string with spaces: \n");
  fgets(userStr, INPUT_STR_SIZE, stdin);
  StrSpaceToHyphen(userStr);
  printf("String with hyphens: %s\n", userStr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1040 <fgets@plt>
lea    -0x50(%rbp),%rdi
call   1050 <StrSpaceToHyphen@plt>
lea    0xe9a(%rip),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <StrSpaceToHyphen@plt>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter string with spaces: \0A\00"
@stdin = global i32 0
@.str.1 = [25 x i8] c"String with hyphens: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
store i32 50, i32* %2
%4 = call i8* @llvm.stacksave()
store i8* %4, i8** %3
%5 = alloca i8, i64 50
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %5, i32 50, i32 %7)
%9 = call i32 @StrSpaceToHyphen(i8* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %5)
store i32 0, i32* %1
%11 = load i8*, i8** %3
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [25 x i8] c"String with hyphens: %s\0A\00"
@str = [27 x i8] c"Enter string with spaces: \00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 50, i32 %4)
%6 = call i32 @StrSpaceToHyphen(i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}