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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1158 <test+0x48>
mov    $0x1,%edi
call   1030 <hash@plt>
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    1122 <test+0x12>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1231 <test+0x121>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11e1 <test+0xd1>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    $0x2,%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    1193 <test+0x83>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     121e <test+0x10e>
mov    $0x1,%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    11ea <test+0xda>
jmp    1223 <test+0x113>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115f <test+0x4f>
cmpl   $0x2,-0x4(%rbp)
jl     12b1 <test+0x1a1>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0x4(%rbp),%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     12ac <test+0x19c>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0x4(%rbp),%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    -0x4(%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    125e <test+0x14e>
jmp    12b1 <test+0x1a1>
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
test   %edi,%edi
jle    12b3 <test+0x1a3>
mov    %edi,%ebp
mov    %edi,%r15d
neg    %r15d
mov    $0x1,%ebx
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    1130 <test+0x20>
cmp    $0x3,%ebp
jl     1243 <test+0x133>
mov    $0x2,%r14d
mov    $0x3,%r13d
mov    $0xffffffff,%r12d
mov    %ebp,0x4(%rsp)
nopl   (%rax)
mov    %r14d,%ebx
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %r14d,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
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    $0x2,%eax
jne    11b0 <test+0xa0>
lea    0x1(%rbx),%r14d
mov    %r14d,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%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    1200 <test+0xf0>
lea    0x1(%r13),%eax
add    $0xffffffff,%r12d
mov    0x4(%rsp),%ebp
cmp    %ebp,%r13d
mov    %eax,%r13d
jne    1180 <test+0x70>
cmp    $0x2,%ebp
jl     12b3 <test+0x1a3>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %ebp,%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    1270 <test+0x160>
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
store i32 %0, i32* %2
store i32 1, i32* %4
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = call i32 @hash(i32 1)
%11 = call i32 @hash(i32 1)
%12 = load i32, i32* %4
%13 = call i32 @hash(i32 %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
store i32 2, i32* %3
br label %18
18: ; preds = %63, %17
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 1
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %66
23: ; preds = %18
%24 = call i32 @hash(i32 1)
%25 = load i32, i32* %3
%26 = call i32 @hash(i32 %25)
%27 = call i32 @hash(i32 1)
store i32 2, i32* %4
br label %28
28: ; preds = %43, %23
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %46
32: ; preds = %28
%33 = call i32 @hash(i32 1)
%34 = load i32, i32* %3
%35 = call i32 @hash(i32 %34)
%36 = load i32, i32* %4
%37 = call i32 @hash(i32 %36)
%38 = call i32 @hash(i32 2)
%39 = load i32, i32* %3
%40 = call i32 @hash(i32 %39)
%41 = load i32, i32* %4
%42 = call i32 @hash(i32 %41)
br label %43
43: ; preds = %32
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %28
46: ; preds = %28
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %49
49: ; preds = %59, %46
%50 = load i32, i32* %4
%51 = load i32, i32* %2
%52 = icmp sle i32 %50, %51
br i1 %52, label %53, label %62
53: ; preds = %49
%54 = call i32 @hash(i32 1)
%55 = load i32, i32* %3
%56 = call i32 @hash(i32 %55)
%57 = load i32, i32* %4
%58 = call i32 @hash(i32 %57)
br label %59
59: ; preds = %53
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %49
62: ; preds = %49
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %18
66: ; preds = %18
%67 = load i32, i32* %2
%68 = icmp sge i32 %67, 2
br i1 %68, label %69, label %93
69: ; preds = %66
%70 = call i32 @hash(i32 1)
%71 = load i32, i32* %2
%72 = call i32 @hash(i32 %71)
%73 = call i32 @hash(i32 1)
store i32 2, i32* %4
br label %74
74: ; preds = %89, %69
%75 = load i32, i32* %4
%76 = load i32, i32* %2
%77 = icmp sle i32 %75, %76
br i1 %77, label %78, label %92
78: ; preds = %74
%79 = call i32 @hash(i32 1)
%80 = load i32, i32* %2
%81 = call i32 @hash(i32 %80)
%82 = load i32, i32* %4
%83 = call i32 @hash(i32 %82)
%84 = call i32 @hash(i32 2)
%85 = load i32, i32* %2
%86 = call i32 @hash(i32 %85)
%87 = load i32, i32* %4
%88 = call i32 @hash(i32 %87)
br label %89
89: ; preds = %78
%90 = load i32, i32* %4
%91 = add nsw i32 %90, 1
store i32 %91, i32* %4
br label %74
92: ; preds = %74
br label %93
93: ; preds = %92, %66
ret void
}

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