#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 *, ...);
void stackGrowth(int *temp1) {
  int temp2;
  printf("Address of temp1 is %p\n", temp1);
  printf("Address of temp2 i %p\n", &temp2);
  if (temp1 < &temp2)
    printf("Stack is growing downwards\n");
  else
    printf("Stack is growing upwards\n");
}


x86 assembly (clang, -O0):
<stackGrowth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rax
cmp    %rax,-0x8(%rbp)
jae    1161 <stackGrowth+0x51>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116f <stackGrowth+0x5f>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stackGrowth>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x4(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%r14
lea    0xef0(%rip),%rax
lea    0xed0(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Address of temp1 is %p\0A\00"
@.str.1 = [23 x i8] c"Address of temp2 i %p\0A\00"
@.str.2 = [28 x i8] c"Stack is growing downwards\0A\00"
@.str.3 = [26 x i8] c"Stack is growing upwards\0A\00"
define void @stackGrowth(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %4)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32*, i32** %2
%8 = icmp ult i32* %7, %3
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Address of temp1 is %p\0A\00"
@.str.1 = [23 x i8] c"Address of temp2 i %p\0A\00"
@str = [25 x i8] c"Stack is growing upwards\00"
@str.4 = [27 x i8] c"Stack is growing downwards\00"
define void @stackGrowth(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %0)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp ugt i32* %2, %0
%7 = select i1 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
ret void
}