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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1158 <test+0x48>
mov    $0x1,%edi
call   1030 <hash@plt>
xor    %edi,%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    1125 <test+0x15>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b9 <test+0xa9>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11a6 <test+0x96>
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    1172 <test+0x62>
jmp    11ab <test+0x9b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <test+0x4f>
add    $0x10,%rsp
pop    %rbp
ret

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

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