#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 = 0; i <= M; i++) {
    {
      hash(1);
      hash(i);
    };
    for (j = 0; j <= N; j++) {
      {
        hash(2);
        hash(i);
        hash(j);
      };
      {
        hash(3);
        hash(i);
        hash(j);
      };
    }
    {
      hash(4);
      hash(i);
    };
  }
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b8 <test+0xa8>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1198 <test+0x88>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    -0x10(%rbp),%edi
call   1030 <hash@plt>
mov    $0x3,%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>
mov    $0x4,%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>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
js     11aa <test+0x9a>
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x1(%r14),%r12d
xor    %ebx,%ebx
jmp    114b <test+0x3b>
xchg   %ax,%ax
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
lea    0x1(%rbx),%eax
cmp    %r15d,%ebx
mov    %eax,%ebx
je     11aa <test+0x9a>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
test   %r14d,%r14d
js     1130 <test+0x20>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    $0x3,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1170 <test+0x60>
jmp    1130 <test+0x20>
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 0, i32* %5
br label %7
7: ; preds = %37, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %40
11: ; preds = %7
%12 = call i32 @hash(i32 1)
%13 = load i32, i32* %5
%14 = call i32 @hash(i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %30, %11
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %33
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)
%25 = call i32 @hash(i32 3)
%26 = load i32, i32* %5
%27 = call i32 @hash(i32 %26)
%28 = load i32, i32* %6
%29 = call i32 @hash(i32 %28)
br label %30
30: ; preds = %19
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %15
33: ; preds = %15
%34 = call i32 @hash(i32 4)
%35 = load i32, i32* %5
%36 = call i32 @hash(i32 %35)
br label %37
37: ; preds = %33
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %7
40: ; preds = %7
ret void
}

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