#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int inner(const char *outer_local, const char *middle_frame) {
  const char local = 0;
  fprintf(stderr,
          "inner: outer_local = %p, &local = %p, "
          "middle_frame = %p\n",
          outer_local, &local, middle_frame);
  if (outer_local >= &local) {
    int inner_below_middle = middle_frame >= &local;
    int middle_below_outer = outer_local >= middle_frame;
    fprintf(stderr,
            "inner: stack grows downwards, "
            " middle_below_outer %d, inner_below_middle %d\n",
            middle_below_outer, inner_below_middle);
    return middle_below_outer && inner_below_middle;
  } else {
    int inner_above_middle = middle_frame <= &local;
    int middle_above_outer = outer_local <= middle_frame;
    fprintf(stderr,
            "inner: stack grows upwards, "
            " middle_above_outer %d, inner_above_middle %d\n",
            middle_above_outer, inner_above_middle);
    return middle_above_outer && inner_above_middle;
  }
}


x86 assembly (clang, -O0):
<inner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xec4(%rip),%rsi
lea    -0x19(%rbp),%rcx
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x19(%rbp),%rax
cmp    %rax,-0x10(%rbp)
jb     11c1 <inner+0xb1>
lea    -0x19(%rbp),%rax
cmp    %rax,-0x18(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x2d(%rbp)
je     11b1 <inner+0xa1>
cmpl   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1228 <inner+0x118>
lea    -0x19(%rbp),%rax
cmp    %rax,-0x18(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
setbe  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x2e(%rbp)
je     121d <inner+0x10d>
cmpl   $0x0,-0x28(%rbp)
setne  %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inner>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0xf(%rsp)
mov    0x2eb2(%rip),%r12
mov    (%r12),%edi
lea    0xec7(%rip),%rsi
lea    0xf(%rsp),%rbx
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %ebp,%ebp
cmp    %r15,%rbx
jbe    1171 <inner+0x61>
cmp    %r14,%rbx
setae  %bpl
xor    %ebx,%ebx
cmp    %r14,%r15
setbe  %bl
mov    (%r12),%edi
lea    0xf17(%rip),%rsi
jmp    118b <inner+0x7b>
cmp    %r14,%rbx
setbe  %bpl
xor    %ebx,%ebx
cmp    %r14,%r15
setae  %bl
mov    (%r12),%edi
lea    0xeae(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
and    %bpl,%bl
movzbl %bl,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"inner: outer_local = %p, &local = %p, middle_frame = %p\0A\00"
@.str.1 = [77 x i8] c"inner: stack grows downwards, middle_below_outer %d, inner_below_middle %d\0A\00"
@.str.2 = [75 x i8] c"inner: stack grows upwards, middle_above_outer %d, inner_above_middle %d\0A\00"
define i32 @inner(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 0, i8* %6
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %6, i8* %13)
%15 = load i8*, i8** %4
%16 = icmp uge i8* %15, %6
br i1 %16, label %17, label %37
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = icmp uge i8* %18, %6
%20 = zext i1 %19 to i32
store i32 %20, i32* %7
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = icmp uge i8* %21, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %8
%25 = load i32, i32* @stderr
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %17
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %31, %17
%35 = phi i1 [ false, %17 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
store i32 %36, i32* %3
br label %57
37: ; preds = %2
%38 = load i8*, i8** %5
%39 = icmp ule i8* %38, %6
%40 = zext i1 %39 to i32
store i32 %40, i32* %9
%41 = load i8*, i8** %4
%42 = load i8*, i8** %5
%43 = icmp ule i8* %41, %42
%44 = zext i1 %43 to i32
store i32 %44, i32* %10
%45 = load i32, i32* @stderr
%46 = load i32, i32* %10
%47 = load i32, i32* %9
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %46, i32 %47)
%49 = load i32, i32* %10
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %37
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br label %54
54: ; preds = %51, %37
%55 = phi i1 [ false, %37 ], [ %53, %51 ]
%56 = zext i1 %55 to i32
store i32 %56, i32* %3
br label %57
57: ; preds = %54, %34
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"inner: outer_local = %p, &local = %p, middle_frame = %p\0A\00"
@.str.1 = [77 x i8] c"inner: stack grows downwards, middle_below_outer %d, inner_below_middle %d\0A\00"
@.str.2 = [75 x i8] c"inner: stack grows upwards, middle_above_outer %d, inner_above_middle %d\0A\00"
define i32 @inner(i8* %0, i8* %1) {
%3 = alloca i8
store i8 0, i8* %3
%4 = load i32, i32* @stderr
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %3, i8* %1)
%6 = icmp ugt i8* %3, %0
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = icmp ule i8* %3, %1
%9 = zext i1 %8 to i32
%10 = icmp uge i8* %0, %1
%11 = zext i1 %10 to i32
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %9)
%14 = and i1 %10, %8
br label %23
15: ; preds = %2
%16 = icmp uge i8* %3, %1
%17 = zext i1 %16 to i32
%18 = icmp ule i8* %0, %1
%19 = zext i1 %18 to i32
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %17)
%22 = and i1 %18, %16
br label %23
23: ; preds = %15, %7
%24 = phi i1 [ %14, %7 ], [ %22, %15 ]
%25 = zext i1 %24 to i32
ret i32 %25
}