#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*/ sink(char *);
int /*<<< orphan*/ strcpy(char *, char *);
void vla_int_strcpy(int n) {
  char a[9 < n ? 9 : n];
  strcpy(a, "012345678");
  sink(a);
  strcpy(a, "01234567");
  sink(a);
}


x86 assembly (clang, -O0):
<vla_int_strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x9,%eax
cmp    -0x4(%rbp),%eax
jge    1146 <vla_int_strcpy+0x26>
mov    $0x9,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <vla_int_strcpy+0x2c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
lea    0xe85(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x28(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vla_int_strcpy>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
cmp    $0x9,%edi
mov    $0x9,%eax
cmovl  %edi,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <sink@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <sink@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"012345678\00"
@.str.1 = [9 x i8] c"01234567\00"
define void @vla_int_strcpy(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 9, %5
br i1 %6, label %7, label %8
7: ; preds = %1
br label %10
8: ; preds = %1
%9 = load i32, i32* %2
br label %10
10: ; preds = %8, %7
%11 = phi i32 [ 9, %7 ], [ %9, %8 ]
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %3
%14 = alloca i8, i64 %12
store i64 %12, i64* %4
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @sink(i8* %14)
%17 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @sink(i8* %14)
%19 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"012345678\00"
@.str.1 = [9 x i8] c"01234567\00"
define void @vla_int_strcpy(i32 %0) {
%2 = icmp slt i32 %0, 9
%3 = select i1 %2, i32 %0, i32 9
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @sink(i8* %5)
%8 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sink(i8* %5)
ret void
}