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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1204 <test+0xf4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11f1 <test+0xe1>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%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     11c9 <test+0xb9>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%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    -0x8(%rbp),%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    116b <test+0x5b>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%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    113c <test+0x2c>
jmp    11f6 <test+0xe6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <test+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11f3 <test+0xe3>
mov    %edi,%r14d
mov    %edi,%r12d
neg    %r12d
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%r15d
lea    0x1(%r15),%r13d
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    %r13d,%ebx
nopl   0x0(%rax)
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    $0x3,%edi
call   1030 <hash@plt>
mov    %r15d,%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    1170 <test+0x60>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
lea    0x1(%rbp),%eax
cmp    %r14d,%ebp
mov    %eax,%ebp
jne    1150 <test+0x40>
cmp    %r14d,%r13d
jne    1140 <test+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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