#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 = 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   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1191 <test+0x81>
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     117e <test+0x6e>
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    114a <test+0x3a>
jmp    1183 <test+0x73>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1125 <test+0x15>
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     11d1 <test+0xc1>
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    119a <test+0x8a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
test   %esi,%esi
jle    118d <test+0x7d>
mov    %edi,%r14d
mov    %edi,%r12d
neg    %r12d
mov    $0x1,%ebp
jmp    113a <test+0x2a>
nop
lea    0x1(%rbp),%eax
cmp    %r15d,%ebp
mov    %eax,%ebp
je     118d <test+0x7d>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
test   %r14d,%r14d
jle    1130 <test+0x20>
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    1160 <test+0x50>
jmp    1130 <test+0x20>
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     11a0 <test+0x90>
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 1, i32* %5
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = call i32 @hash(i32 1)
%13 = load i32, i32* %5
%14 = call i32 @hash(i32 %13)
store i32 1, i32* %6
br label %15
15: ; preds = %25, %11
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = call i32 @hash(i32 2)
%21 = load i32, i32* %5
%22 = call i32 @hash(i32 %21)
%23 = load i32, i32* %6
%24 = call i32 @hash(i32 %23)
br label %25
25: ; preds = %19
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %7
32: ; preds = %7
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %35
35: ; preds = %45, %32
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = add nsw i32 1000, %37
%39 = add nsw i32 %38, 1
%40 = icmp sle i32 %36, %39
br i1 %40, label %41, label %48
41: ; preds = %35
%42 = call i32 @hash(i32 1)
%43 = load i32, i32* %5
%44 = call i32 @hash(i32 %43)
br label %45
45: ; preds = %41
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %35
48: ; preds = %35
ret void
}

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