int main() {
  printf("Please enter a String: ");
  char *strIn = getStr();
  printf("%d\n", length(strIn));
  strIn = multiplyStr(strIn, length(strIn), 2);
  printf("%s\n", strIn);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getStr@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <length@plt>
mov    %eax,%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <length@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%esi
mov    $0x2,%edx
mov    $0x0,%al
call   1050 <multiplyStr@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getStr@plt>
movslq %eax,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <length@plt>
lea    0xe9e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <length@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1060 <multiplyStr@plt>
movslq %eax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Please enter a String: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @getStr()
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @length to i32 (i8*, ...)*)(i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %1
%10 = load i8*, i8** %1
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @length to i32 (i8*, ...)*)(i8* %10)
%12 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @multiplyStr to i32 (i8*, i32, i32, ...)*)(i8* %9, i32 %11, i32 2)
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %1
%15 = load i8*, i8** %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please enter a String: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getStr()
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @length to i32 (i8*, ...)*)(i8* %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @length to i32 (i8*, ...)*)(i8* %4)
%8 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @multiplyStr to i32 (i8*, i32, i32, ...)*)(i8* %4, i32 %7, i32 2)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}