#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 expand(char *, char *);
int /*<<< orphan*/ printf(char *, char *, int);
void main() {
  char str[1000];
  int len;
  len = expand("alphabet: C-Zc-z et a-z0-9 -3-8", str);
  printf("New string : %s\nSize : %d\n", str, len);
  len = expand(
      "-a-z0-9 SOMETHING HERE a-f-r blah blahblah -0-2?! 0-0 9-9 8-5 -", str);
  printf("New string : %s\nSize : %d\n", str, len);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    -0x3f0(%rbp),%rsi
lea    0xec7(%rip),%rdi
call   1040 <expand@plt>
mov    %eax,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rsi
mov    -0x3f4(%rbp),%edx
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xed0(%rip),%rdi
call   1040 <expand@plt>
mov    %eax,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rsi
mov    -0x3f4(%rbp),%edx
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
lea    0xecf(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <expand@plt>
lea    0xedd(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    %rbx,%rsi
call   1040 <expand@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"alphabet: C-Zc-z et a-z0-9 -3-8\00"
@.str.1 = [27 x i8] c"New string : %s\0ASize : %d\0A\00"
@.str.2 = [64 x i8] c"-a-z0-9 SOMETHING HERE a-f-r blah blahblah -0-2?! 0-0 9-9 8-5 -\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = call i32 @expand(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %3)
store i32 %4, i32* %2
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %6)
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%9 = call i32 @expand(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %8)
store i32 %9, i32* %2
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"alphabet: C-Zc-z et a-z0-9 -3-8\00"
@.str.1 = [27 x i8] c"New string : %s\0ASize : %d\0A\00"
@.str.2 = [64 x i8] c"-a-z0-9 SOMETHING HERE a-f-r blah blahblah -0-2?! 0-0 9-9 8-5 -\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i32 @expand(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %3)
%5 = call i32 @expand(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %5)
ret void
}