#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*/ smash(char *, int);
int test1(int n) {
  int i;
  char *array_ptrs[1000];
  for (i = 0; i < 1000; ++i) {
    char test[n];
    smash(test, n);
    array_ptrs[i] = test;
  }
  return (array_ptrs[0] - array_ptrs[1000 - 1] < n) ? 0 : 1;
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f70,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    1194 <test1+0x84>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x1f58(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x1f68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x1f60(%rbp)
mov    -0x4(%rbp),%esi
call   1030 <smash@plt>
mov    -0x1f68(%rbp),%rcx
movslq -0x8(%rbp),%rax
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
mov    -0x1f58(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <test1+0x15>
mov    -0x1f50(%rbp),%rdx
mov    -0x18(%rbp),%rax
sub    %rax,%rdx
movslq -0x4(%rbp),%rsi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %rsi,%rdx
cmovl  %ecx,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f48,%rsp
mov    %edi,%r14d
mov    %edi,%r15d
xor    %r12d,%r12d
add    $0xf,%r15
and    $0xfffffffffffffff0,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rsp,%r13
mov    %rsp,%rbx
sub    %r15,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <smash@plt>
mov    %rbx,-0x1f70(%rbp,%r12,8)
ff
mov    %r13,%rsp
add    $0x1,%r12
cmp    $0x3e8,%r12
jne    1140 <test1+0x30>
mov    -0x1f70(%rbp),%rcx
sub    -0x38(%rbp),%rcx
movslq %r14d,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
setge  %al
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test1(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8*]
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 1000
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = load i32, i32* %2
%16 = call i32 @smash(i8* %14, i32 %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %4, i64 0, i64 %18
store i8* %14, i8** %19
%20 = load i8*, i8** %5
br label %21
21: ; preds = %10
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %7
24: ; preds = %7
%25 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %4, i64 0, i64 0
%26 = load i8*, i8** %25
%27 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %4, i64 0, i64 999
%28 = load i8*, i8** %27
%29 = ptrtoint i8* %26 to i64
%30 = ptrtoint i8* %28 to i64
%31 = sub i64 %29, %30
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 0, i32 1
ret i32 %36
}

LLVM IR (-O2):
define i32 @test1(i32 %0) {
%2 = alloca [1000 x i8*]
%3 = bitcast [1000 x i8*]* %2 to i8*
%4 = zext i32 %0 to i64
br label %5
5: ; preds = %1, %5
%6 = phi i64 [ 0, %1 ], [ %11, %5 ]
%7 = call i8* @llvm.stacksave()
%8 = alloca i8, i64 %4
%9 = call i32 @smash(i8* %8, i32 %0)
%10 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %6
store i8* %8, i8** %10
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 1000
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 999
%17 = load i8*, i8** %16
%18 = ptrtoint i8* %15 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = sext i32 %0 to i64
%22 = icmp sge i64 %20, %21
%23 = zext i1 %22 to i32
ret i32 %23
}