#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long);
int /*<<< orphan*/ stderr;
long check_limit(long i, long N) {
  if (i == N)
    return 0;
  if (i < 0 || i > N) {
    fprintf(stderr, "particle assigned to unexisting cell %ld\nExiting...", i);
    exit(0);
  }
  return i;
}


x86 assembly (clang, -O0):
<check_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    114b <check_limit+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    118c <check_limit+0x6c>
cmpq   $0x0,-0x10(%rbp)
jl     1164 <check_limit+0x44>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    1184 <check_limit+0x64>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe88(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_limit>:
cmp    %rsi,%rdi
jne    1128 <check_limit+0x8>
xor    %eax,%eax
ret
mov    %rdi,%rax
test   %rdi,%rdi
js     1136 <check_limit+0x16>
cmp    %rsi,%rax
jg     1136 <check_limit+0x16>
ret
push   %rax
mov    0x2ea2(%rip),%rcx
mov    (%rcx),%edi
lea    0xeb9(%rip),%rsi
mov    %rax,%rdx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"particle assigned to unexisting cell %ld\0AExiting...\00"
define i64 @check_limit(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %4
%7 = load i64, i64* %5
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store i64 0, i64* %3
br label %24
10: ; preds = %2
%11 = load i64, i64* %4
%12 = icmp slt i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i64, i64* %4
%15 = load i64, i64* %5
%16 = icmp sgt i64 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13, %10
%18 = load i32, i32* @stderr
%19 = load i64, i64* %4
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i64 %19)
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %13
%23 = load i64, i64* %4
store i64 %23, i64* %3
br label %24
24: ; preds = %22, %9
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"particle assigned to unexisting cell %ld\0AExiting...\00"
define i64 @check_limit(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, %1
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = icmp slt i64 %0, 0
%6 = icmp sgt i64 %0, %1
%7 = or i1 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i64 %0)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %4, %2
%13 = phi i64 [ 0, %2 ], [ %0, %4 ]
ret i64 %13
}