#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*/ printf(char *, char *);
int /*<<< orphan*/ replace_spaces(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char string[11] = "a b";
  replace_spaces(string, 11);
  printf("%s\n", string);
  strcpy(string, "a bc");
  replace_spaces(string, 11);
  printf("%s\n", string);
  strcpy(string, "a  bc");
  replace_spaces(string, 11);
  printf("%s\n", string);
  strcpy(string, "   a");
  replace_spaces(string, 11);
  printf("%s\n", string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xeaf(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xf(%rbp),%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
lea    -0xf(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    -0xf(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xf(%rbp),%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
lea    -0xf(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
lea    -0xf(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xf(%rbp),%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
lea    -0xf(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
lea    -0xf(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xf(%rbp),%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
lea    -0xf(%rbp),%rsi
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xf(%rsp)
movq   $0x622061,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
lea    0xeaa(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <replace_spaces@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string = [11 x i8] c"a b\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"a bc\00"
@.str.2 = [6 x i8] c"a bc\00"
@.str.3 = [5 x i8] c" a\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
store i32 0, i32* %1
%3 = bitcast [11 x i8]* %2 to i8*
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = call i32 @replace_spaces(i8* %4, i32 11)
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%11 = call i32 @replace_spaces(i8* %10, i32 11)
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%17 = call i32 @replace_spaces(i8* %16, i32 11)
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%23 = call i32 @replace_spaces(i8* %22, i32 11)
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.string = [11 x i8] c"a b\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"a bc\00"
@.str.2 = [6 x i8] c"a bc\00"
@.str.3 = [5 x i8] c" a\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = call i32 @replace_spaces(i8* %2, i32 11)
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @replace_spaces(i8* %2, i32 11)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @replace_spaces(i8* %2, i32 11)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @replace_spaces(i8* %2, i32 11)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}