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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     114e <test+0x3e>
mov    $0x1,%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    1122 <test+0x12>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1181 <test+0x71>
mov    $0x2,%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    1155 <test+0x45>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b4 <test+0xa4>
mov    $0x3,%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    1188 <test+0x78>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     11a8 <test+0x98>
mov    %edi,%r14d
lea    0x1(%r14),%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1130 <test+0x20>
test   %r14d,%r14d
jle    1184 <test+0x74>
mov    %r14d,%r15d
neg    %r15d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2,%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    1160 <test+0x50>
test   %r14d,%r14d
js     11a8 <test+0x98>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x3,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
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
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = call i32 @hash(i32 1)
%11 = load i32, i32* %3
%12 = call i32 @hash(i32 %11)
br label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
store i32 1, i32* %3
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = call i32 @hash(i32 2)
%23 = load i32, i32* %3
%24 = call i32 @hash(i32 %23)
br label %25
25: ; preds = %21
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %17
28: ; preds = %17
store i32 0, i32* %3
br label %29
29: ; preds = %37, %28
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = call i32 @hash(i32 3)
%35 = load i32, i32* %3
%36 = call i32 @hash(i32 %35)
br label %37
37: ; preds = %33
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %29
40: ; preds = %29
ret void
}

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