#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 */
long get_stack_direction();
int /*<<< orphan*/ printf(char *, ...);
void main10(void) {
  long stack_direction = get_stack_direction();
  if (stack_direction > 0) {
    printf("/* Stack grows up, ca. %ld bytes per function call. */\n",
           (long)stack_direction);
    printf("#define stack_grows_up\n");
  } else if (stack_direction < 0) {
    printf("/* Stack grows down, ca. %ld bytes per function call. */\n",
           -(long)stack_direction);
    printf("#define stack_grows_down\n");
  } else
    printf("#error \"Unknown stack model -- incorrect C semantics!!\"\n");
}


x86 assembly (clang, -O0):
<main10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <get_stack_direction@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jle    1163 <main10+0x43>
mov    -0x8(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main10+0x8a>
cmpq   $0x0,-0x8(%rbp)
jge    1197 <main10+0x77>
xor    %eax,%eax
mov    %eax,%esi
sub    -0x8(%rbp),%rsi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <main10+0x85>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main10+0x8a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main10>:
push   %rax
xor    %eax,%eax
call   1050 <get_stack_direction@plt>
test   %rax,%rax
jle    115b <main10+0x2b>
lea    0xebc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf6e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
js     116a <main10+0x3a>
lea    0xf0e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
neg    %rax
lea    0xec4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf25(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"/* Stack grows up, ca. %ld bytes per function call. */\0A\00"
@.str.1 = [24 x i8] c"#define stack_grows_up\0A\00"
@.str.2 = [58 x i8] c"/* Stack grows down, ca. %ld bytes per function call. */\0A\00"
@.str.3 = [26 x i8] c"#define stack_grows_down\0A\00"
@.str.4 = [57 x i8] c"#error \22Unknown stack model -- incorrect C semantics!!\22\0A\00"
define void @main10() {
%1 = alloca i64
%2 = call i64 (...) @get_stack_direction()
store i64 %2, i64* %1
%3 = load i64, i64* %1
%4 = icmp sgt i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i64, i64* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %20
9: ; preds = %0
%10 = load i64, i64* %1
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i64, i64* %1
%14 = sub nsw i64 0, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
br label %20
20: ; preds = %19, %5
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"/* Stack grows up, ca. %ld bytes per function call. */\0A\00"
@.str.2 = [58 x i8] c"/* Stack grows down, ca. %ld bytes per function call. */\0A\00"
@str = [56 x i8] c"#error \22Unknown stack model -- incorrect C semantics!!\22\00"
@str.5 = [25 x i8] c"#define stack_grows_down\00"
@str.6 = [23 x i8] c"#define stack_grows_up\00"
define void @main10() {
%1 = tail call i64 (...) @get_stack_direction()
%2 = icmp sgt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i64 %1)
br label %10
5: ; preds = %0
%6 = icmp slt i64 %1, 0
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = sub nsw i64 0, %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i64 %8)
br label %10
10: ; preds = %5, %7, %3
%11 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), %3 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0), %5 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
ret void
}