#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 */
unsigned long check_stack(unsigned long *);
unsigned long check_stack_stop(unsigned long *base) {
  unsigned long i;
  unsigned long from, to;
  to = check_stack(&from);
  *base = from;
  for (i = from; i < to; i += 4) {
    if ((*(long *)i) != 0xdeadbeef)
      break;
  }
  return i;
}


x86 assembly (clang, -O0):
<check_stack_stop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <check_stack@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1177 <check_stack_stop+0x67>
mov    -0x10(%rbp),%rax
mov    $0xdeadbeef,%ecx
cmp    %rcx,(%rax)
je     1161 <check_stack_stop+0x51>
jmp    1177 <check_stack_stop+0x67>
jmp    1166 <check_stack_stop+0x56>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <check_stack_stop+0x2c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_stack_stop>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1030 <check_stack@plt>
mov    %rax,%rcx
mov    0x8(%rsp),%rax
mov    %rax,(%rbx)
cmp    %rcx,%rax
jae    114e <check_stack_stop+0x3e>
mov    $0xdeadbeef,%edx
nopw   0x0(%rax,%rax,1)
cmp    %rdx,(%rax)
jne    114e <check_stack_stop+0x3e>
add    $0x4,%rax
cmp    %rcx,%rax
jb     1140 <check_stack_stop+0x30>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i64 @check_stack_stop(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64* %0, i64** %2
%6 = call i64 @check_stack(i64* %4)
store i64 %6, i64* %5
%7 = load i64, i64* %4
%8 = load i64*, i64** %2
store i64 %7, i64* %8
%9 = load i64, i64* %4
store i64 %9, i64* %3
br label %10
10: ; preds = %21, %1
%11 = load i64, i64* %3
%12 = load i64, i64* %5
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i64, i64* %3
%16 = inttoptr i64 %15 to i64*
%17 = load i64, i64* %16
%18 = icmp ne i64 %17, 3735928559
br i1 %18, label %19, label %20
19: ; preds = %14
br label %24
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i64, i64* %3
%23 = add i64 %22, 4
store i64 %23, i64* %3
br label %10
24: ; preds = %19, %10
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
define i64 @check_stack_stop(i64* nocapture writeonly %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = call i64 @check_stack(i64* %2)
%5 = load i64, i64* %2
store i64 %5, i64* %0
%6 = icmp ult i64 %5, %4
br i1 %6, label %7, label %15
7: ; preds = %1, %12
%8 = phi i64 [ %13, %12 ], [ %5, %1 ]
%9 = inttoptr i64 %8 to i64*
%10 = load i64, i64* %9
%11 = icmp eq i64 %10, 3735928559
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = add i64 %8, 4
%14 = icmp ult i64 %13, %4
br i1 %14, label %7, label %15
15: ; preds = %12, %7, %1
%16 = phi i64 [ %5, %1 ], [ %8, %7 ], [ %13, %12 ]
ret i64 %16
}