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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117d <test+0x6d>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%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    113d <test+0x2d>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1208 <test+0xf8>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11f5 <test+0xe5>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    $0x1,%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    11b7 <test+0xa7>
jmp    11fa <test+0xea>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <test+0x74>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x4(%rbp),%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
cmp    $0x2,%r14d
jl     120a <test+0xfa>
mov    %r14d,%r15d
neg    %r15d
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1150 <test+0x40>
cmp    $0x3,%r14d
jl     120a <test+0xfa>
mov    $0x2,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%ebx
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r12d,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
lea    0x1(%rbx),%r12d
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11d0 <test+0xc0>
cmp    %r14d,%r12d
jne    11a0 <test+0x90>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r14d,%edi
call   1030 <hash@plt>
xor    %edi,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <hash@plt>

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

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