#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*/ hash(int);
void test(int M, int N) {
  int i, j;
  for (i = -1000 + 0; i <= 0; i++) {
    {
      hash(1);
      hash(i);
    };
  }
  for (i = 1; i <= N; i++) {
    {
      hash(1);
      hash(i);
    };
    for (j = 1; j <= M; j++) {
      {
        hash(2);
        hash(i);
        hash(j);
      };
    }
  }
  for (i = N + 1; i <= 1000 + N + 1; i++) {
    {
      hash(1);
      hash(i);
    };
  }
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xfffffc18,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     114f <test+0x3f>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1125 <test+0x15>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c2 <test+0xb2>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11af <test+0x9f>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    -0x10(%rbp),%edi
call   1030 <hash@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117b <test+0x6b>
jmp    11b4 <test+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <test+0x46>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x3e8,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     1202 <test+0xf2>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cb <test+0xbb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
mov    $0xfffffc17,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edi
call   1030 <hash@plt>
lea    0x1(%rbx),%edi
call   1030 <hash@plt>
inc    %ebx
jne    1130 <test+0x20>
test   %r15d,%r15d
jle    11bd <test+0xad>
mov    %r14d,%r12d
neg    %r12d
mov    $0x1,%ebp
jmp    116a <test+0x5a>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbp),%eax
cmp    %r15d,%ebp
mov    %eax,%ebp
je     11bd <test+0xad>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
test   %r14d,%r14d
jle    1160 <test+0x50>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
lea    (%r12,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1190 <test+0x80>
jmp    1160 <test+0x50>
lea    0x3e8(%r15),%ebp
add    $0xffffffff,%r15d
nopl   0x0(%rax,%rax,1)
lea    0x2(%r15),%ebx
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
add    $0x1,%r15d
cmp    %ebp,%r15d
jl     11d0 <test+0xc0>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @test(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 -1000, i32* %5
br label %7
7: ; preds = %14, %2
%8 = load i32, i32* %5
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = call i32 @hash(i32 1)
%12 = load i32, i32* %5
%13 = call i32 @hash(i32 %12)
br label %14
14: ; preds = %10
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %7
17: ; preds = %7
store i32 1, i32* %5
br label %18
18: ; preds = %40, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %43
22: ; preds = %18
%23 = call i32 @hash(i32 1)
%24 = load i32, i32* %5
%25 = call i32 @hash(i32 %24)
store i32 1, i32* %6
br label %26
26: ; preds = %36, %22
%27 = load i32, i32* %6
%28 = load i32, i32* %3
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = call i32 @hash(i32 2)
%32 = load i32, i32* %5
%33 = call i32 @hash(i32 %32)
%34 = load i32, i32* %6
%35 = call i32 @hash(i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %26
39: ; preds = %26
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %18
43: ; preds = %18
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %46
46: ; preds = %56, %43
%47 = load i32, i32* %5
%48 = load i32, i32* %4
%49 = add nsw i32 1000, %48
%50 = add nsw i32 %49, 1
%51 = icmp sle i32 %47, %50
br i1 %51, label %52, label %59
52: ; preds = %46
%53 = call i32 @hash(i32 1)
%54 = load i32, i32* %5
%55 = call i32 @hash(i32 %54)
br label %56
56: ; preds = %52
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %46
59: ; preds = %46
ret void
}

LLVM IR (-O2):
define void @test(i32 %0, i32 %1) {
br label %7
3: ; preds = %7
%4 = icmp slt i32 %1, 1
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = icmp slt i32 %0, 1
br label %15
7: ; preds = %2, %7
%8 = phi i32 [ -1000, %2 ], [ %11, %7 ]
%9 = tail call i32 @hash(i32 1)
%10 = tail call i32 @hash(i32 %8)
%11 = add nsw i32 %8, 1
%12 = icmp eq i32 %8, 0
br i1 %12, label %3, label %7
13: ; preds = %26, %3
%14 = add nsw i32 %1, 1000
br label %29
15: ; preds = %5, %26
%16 = phi i32 [ 1, %5 ], [ %27, %26 ]
%17 = tail call i32 @hash(i32 1)
%18 = tail call i32 @hash(i32 %16)
br i1 %6, label %26, label %19
19: ; preds = %15, %19
%20 = phi i32 [ %24, %19 ], [ 1, %15 ]
%21 = tail call i32 @hash(i32 2)
%22 = tail call i32 @hash(i32 %16)
%23 = tail call i32 @hash(i32 %20)
%24 = add nuw i32 %20, 1
%25 = icmp eq i32 %20, %0
br i1 %25, label %26, label %19
26: ; preds = %19, %15
%27 = add nuw i32 %16, 1
%28 = icmp eq i32 %16, %1
br i1 %28, label %13, label %15
29: ; preds = %13, %29
%30 = phi i32 [ %1, %13 ], [ %31, %29 ]
%31 = add nsw i32 %30, 1
%32 = tail call i32 @hash(i32 1)
%33 = tail call i32 @hash(i32 %31)
%34 = icmp slt i32 %30, %14
br i1 %34, label %29, label %35
35: ; preds = %29
ret void
}