#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, int, ...);
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",
          (void *)outer_local, (void *)&local, (void *)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),%rax
mov    %eax,%edx
lea    -0x19(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%r8
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x19(%rbp),%rax
cmp    %rax,-0x10(%rbp)
jb     11c5 <inner+0xb5>
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    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x2d(%rbp)
je     11b5 <inner+0xa5>
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    122c <inner+0x11c>
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    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x2e(%rbp)
je     1221 <inner+0x111>
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    0xf(%rsp),%rbx
lea    0xec2(%rip),%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %ebp,%ebp
cmp    %r15,%rbx
jbe    1170 <inner+0x60>
cmp    %r14,%rbx
setae  %bpl
xor    %ebx,%ebx
cmp    %r14,%r15
setbe  %bl
mov    (%r12),%edi
lea    0xf18(%rip),%rsi
jmp    118a <inner+0x7a>
cmp    %r14,%rbx
setbe  %bpl
xor    %ebx,%ebx
cmp    %r14,%r15
setae  %bl
mov    (%r12),%edi
lea    0xeaf(%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 = ptrtoint i8* %12 to i32
%14 = ptrtoint i8* %6 to i32
%15 = load i8*, i8** %5
%16 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i8* %15)
%17 = load i8*, i8** %4
%18 = icmp uge i8* %17, %6
br i1 %18, label %19, label %39
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = icmp uge i8* %20, %6
%22 = zext i1 %21 to i32
store i32 %22, i32* %7
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = icmp uge i8* %23, %24
%26 = zext i1 %25 to i32
store i32 %26, i32* %8
%27 = load i32, i32* @stderr
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %19
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
br label %36
36: ; preds = %33, %19
%37 = phi i1 [ false, %19 ], [ %35, %33 ]
%38 = zext i1 %37 to i32
store i32 %38, i32* %3
br label %59
39: ; preds = %2
%40 = load i8*, i8** %5
%41 = icmp ule i8* %40, %6
%42 = zext i1 %41 to i32
store i32 %42, i32* %9
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = icmp ule i8* %43, %44
%46 = zext i1 %45 to i32
store i32 %46, i32* %10
%47 = load i32, i32* @stderr
%48 = load i32, i32* %10
%49 = load i32, i32* %9
%50 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %48, i32 %49)
%51 = load i32, i32* %10
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %39
%54 = load i32, i32* %9
%55 = icmp ne i32 %54, 0
br label %56
56: ; preds = %53, %39
%57 = phi i1 [ false, %39 ], [ %55, %53 ]
%58 = zext i1 %57 to i32
store i32 %58, i32* %3
br label %59
59: ; preds = %56, %36
%60 = load i32, i32* %3
ret i32 %60
}

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 = ptrtoint i8* %0 to i64
%6 = trunc i64 %5 to i32
%7 = ptrtoint i8* %3 to i64
%8 = trunc i64 %7 to i32
%9 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i8* %1)
%10 = icmp ugt i8* %3, %0
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = icmp ule i8* %3, %1
%13 = zext i1 %12 to i32
%14 = icmp uge i8* %0, %1
%15 = zext i1 %14 to i32
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %13)
%18 = and i1 %14, %12
br label %27
19: ; preds = %2
%20 = icmp uge i8* %3, %1
%21 = zext i1 %20 to i32
%22 = icmp ule i8* %0, %1
%23 = zext i1 %22 to i32
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %21)
%26 = and i1 %22, %20
br label %27
27: ; preds = %19, %11
%28 = phi i1 [ %18, %11 ], [ %26, %19 ]
%29 = zext i1 %28 to i32
ret i32 %29
}