#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*/ printf(char *);
fun(char *x) {
  if (x < (char *)&x)
    printf("STACK GROWS UP\n");
  else
    printf("STACK GROWS DOWN\n");
  if (&x[0] < &x[10])
    printf("ARRAYS GROW UP\n");
  else
    printf("ARRAYS GROW DOWN\n");
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x10(%rbp),%rcx
cmp    %rcx,%rax
jae    113e <fun+0x2e>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
jmp    114a <fun+0x3a>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0xa,%rcx
cmp    %rcx,%rax
jae    1170 <fun+0x60>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    117c <fun+0x6c>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rax
mov    %rdi,(%rsp)
mov    %rsp,%rax
cmp    %rdi,%rax
lea    0xefe(%rip),%rax
lea    0xed7(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"STACK GROWS UP\0A\00"
@.str.1 = [18 x i8] c"STACK GROWS DOWN\0A\00"
@.str.2 = [16 x i8] c"ARRAYS GROW UP\0A\00"
@.str.3 = [18 x i8] c"ARRAYS GROW DOWN\0A\00"
define i32 @fun(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = bitcast i8** %3 to i8*
%6 = icmp ult i8* %4, %5
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 10
%16 = icmp ult i8* %13, %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@str = [17 x i8] c"STACK GROWS DOWN\00"
@str.4 = [15 x i8] c"ARRAYS GROW UP\00"
@str.5 = [15 x i8] c"STACK GROWS UP\00"
define i32 @fun(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = bitcast i8** %2 to i8*
%4 = icmp ugt i8* %3, %0
%5 = select i1 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0)
%6 = call i32 @puts(i8* dereferenceable(1) %5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
ret i32 undef
}