#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 */
char *alloca(int);
int /*<<< orphan*/ printf(char *, char *, char *);
char *strcpy(char *, char *);
int strlen(char *);
int test17() {
  char *demo = "This is only a test.";
  char *p;
  p = alloca(16);
  strcpy(p, "12345678901234");
  printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)), demo));
  ;
  return 0;
}


x86 assembly (clang, -O0):
<test17>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x10,%edi
call   1060 <alloca@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1060 <alloca@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test17>:
push   %rbx
mov    $0x10,%edi
call   1050 <alloca@plt>
mov    %rax,%rbx
movabs $0x3837363534333231,%rax
36 37 38
mov    %rax,(%rbx)
movabs $0x34333231303938,%rax
mov    %rax,0x7(%rbx)
lea    0xea0(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
call   1050 <alloca@plt>
movabs $0x2e747365742061,%rcx
mov    %rcx,0xd(%rax)
movups 0xe7f(%rip),%xmm0
movups %xmm0,(%rax)
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"This is only a test.\00"
@.str.1 = [15 x i8] c"12345678901234\00"
@.str.2 = [18 x i8] c"alloca : %s : %s\0A\00"
define i32 @test17() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i8* @alloca(i32 16)
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strcpy(i8* %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = load i8*, i8** %1
%8 = call i32 @strlen(i8* %7)
%9 = call i8* @alloca(i32 %8)
%10 = load i8*, i8** %1
%11 = call i8* @strcpy(i8* %9, i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"This is only a test.\00"
@.str.1 = [15 x i8] c"12345678901234\00"
@.str.2 = [18 x i8] c"alloca : %s : %s\0A\00"
define i32 @test17() {
%1 = tail call i8* @alloca(i32 16)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(15) %1, i8* align 1 dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 15, i1 false)
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @alloca(i32 %2)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(21) %3, i8* align 1 dereferenceable(21) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 21, i1 false)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %3)
ret i32 0
}