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


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>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     120c <test+0xfc>
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
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11e4 <test+0xd4>
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    11ab <test+0x9b>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117c <test+0x6c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0x3,%r15d
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
cmp    $0x3,%r14d
jl     1218 <test+0x108>
mov    $0xffffffff,%ebx
nopl   0x0(%rax)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x2,%eax
jne    11c0 <test+0xb0>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
lea    0x1(%r15),%eax
add    $0xffffffff,%ebx
cmp    %r14d,%r15d
mov    %eax,%r15d
jne    1190 <test+0x80>
add    $0x8,%rsp
pop    %rbx
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
%5 = call i32 @hash(i32 3)
%6 = call i32 @hash(i32 1)
%7 = call i32 @hash(i32 1)
%8 = call i32 @hash(i32 1)
%9 = call i32 @hash(i32 2)
%10 = call i32 @hash(i32 1)
%11 = call i32 @hash(i32 4)
%12 = call i32 @hash(i32 2)
%13 = call i32 @hash(i32 2)
store i32 3, i32* %3
br label %14
14: ; preds = %43, %1
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = call i32 @hash(i32 1)
%20 = load i32, i32* %3
%21 = call i32 @hash(i32 %20)
%22 = call i32 @hash(i32 1)
store i32 2, i32* %4
br label %23
23: ; preds = %34, %18
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = icmp sle i32 %24, %26
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = call i32 @hash(i32 2)
%30 = load i32, i32* %3
%31 = call i32 @hash(i32 %30)
%32 = load i32, i32* %4
%33 = call i32 @hash(i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %23
37: ; preds = %23
%38 = call i32 @hash(i32 4)
%39 = load i32, i32* %3
%40 = call i32 @hash(i32 %39)
%41 = load i32, i32* %3
%42 = call i32 @hash(i32 %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %14
46: ; preds = %14
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 1)
%5 = tail call i32 @hash(i32 1)
%6 = tail call i32 @hash(i32 2)
%7 = tail call i32 @hash(i32 1)
%8 = tail call i32 @hash(i32 4)
%9 = tail call i32 @hash(i32 2)
%10 = tail call i32 @hash(i32 2)
%11 = icmp slt i32 %0, 3
br i1 %11, label %30, label %12
12: ; preds = %1, %24
%13 = phi i32 [ %28, %24 ], [ 3, %1 ]
%14 = tail call i32 @hash(i32 1)
%15 = tail call i32 @hash(i32 %13)
%16 = tail call i32 @hash(i32 1)
br label %17
17: ; preds = %12, %17
%18 = phi i32 [ %22, %17 ], [ 2, %12 ]
%19 = tail call i32 @hash(i32 2)
%20 = tail call i32 @hash(i32 %13)
%21 = tail call i32 @hash(i32 %18)
%22 = add nuw nsw i32 %18, 1
%23 = icmp eq i32 %22, %13
br i1 %23, label %24, label %17
24: ; preds = %17
%25 = tail call i32 @hash(i32 4)
%26 = tail call i32 @hash(i32 %13)
%27 = tail call i32 @hash(i32 %13)
%28 = add nuw i32 %13, 1
%29 = icmp eq i32 %13, %0
br i1 %29, label %30, label %12
30: ; preds = %24, %1
ret void
}