#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int get_line_length(char *);
char *expand_array(char array[]) {
  static char new_array[sizeof(array) / sizeof(char) * 2];
  for (int i = 0; i < get_line_length(array); ++i) {
    new_array[i] = array[i];
  }
  return new_array;
}


x86 assembly (clang, -O0):
<expand_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_line_length@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    1166 <expand_array+0x56>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0xc(%rbp),%rcx
lea    0x2eeb(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <expand_array+0x13>
lea    0x2ed3(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <get_line_length@plt>
test   %eax,%eax
jle    114c <expand_array+0x3c>
xor    %ebx,%ebx
lea    0x2f16(%rip),%r15
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%eax
mov    %al,(%rbx,%r15,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <get_line_length@plt>
cltq
cmp    %rax,%rbx
jl     1130 <expand_array+0x20>
lea    0x2eed(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@expand_array.new_array = internal global [16 x i8] zeroinitializer
define i8* @expand_array(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %18, %1
%5 = load i32, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @get_line_length(i8* %6)
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %21
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i8], [16 x i8]* @expand_array.new_array, i64 0, i64 %16
store i8 %14, i8* %17
br label %18
18: ; preds = %9
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @expand_array.new_array, i64 0, i64 0)
}

LLVM IR (-O2):
@expand_array.new_array = internal global [16 x i8] zeroinitializer
define i8* @expand_array(i8* %0) {
%2 = tail call i32 @get_line_length(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %5, label %4
4: ; preds = %5, %1
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @expand_array.new_array, i64 0, i64 0)
5: ; preds = %1, %5
%6 = phi i64 [ %10, %5 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = getelementptr inbounds [16 x i8], [16 x i8]* @expand_array.new_array, i64 0, i64 %6
store i8 %8, i8* %9
%10 = add nuw nsw i64 %6, 1
%11 = tail call i32 @get_line_length(i8* %0)
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %10, %12
br i1 %13, label %5, label %4
}