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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117c <test+0x6c>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1169 <test+0x59>
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    1135 <test+0x25>
jmp    116e <test+0x5e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <test+0x12>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11dd <test+0xcd>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11ca <test+0xba>
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    1196 <test+0x86>
jmp    11cf <test+0xbf>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1183 <test+0x73>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    11c5 <test+0xb5>
mov    %edi,%r14d
mov    %edi,%r15d
neg    %r15d
mov    $0x1,%ebx
nopl   (%rax)
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
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    1140 <test+0x30>
lea    0x1(%rbx),%eax
cmp    %r14d,%ebx
mov    %eax,%ebx
jne    1130 <test+0x20>
test   %r14d,%r14d
jle    11c5 <test+0xb5>
mov    $0x1,%ebx
nop
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2,%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    1190 <test+0x80>
lea    0x1(%rbx),%eax
cmp    %r14d,%ebx
mov    %eax,%ebx
jne    1180 <test+0x70>
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
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
store i32 1, i32* %4
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 @hash(i32 1)
%18 = load i32, i32* %3
%19 = call i32 @hash(i32 %18)
%20 = load i32, i32* %4
%21 = call i32 @hash(i32 %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
store i32 1, i32* %3
br label %30
30: ; preds = %49, %29
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %52
34: ; preds = %30
store i32 1, i32* %4
br label %35
35: ; preds = %45, %34
%36 = load i32, i32* %4
%37 = load i32, i32* %2
%38 = icmp sle i32 %36, %37
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = call i32 @hash(i32 2)
%41 = load i32, i32* %3
%42 = call i32 @hash(i32 %41)
%43 = load i32, i32* %4
%44 = call i32 @hash(i32 %43)
br label %45
45: ; preds = %39
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %35
48: ; preds = %35
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %30
52: ; preds = %30
ret void
}

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