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


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1147 <test+0x37>
mov    $0x1,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117a <test+0x6a>
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    114e <test+0x3e>
cmpl   $0xffffffff,-0x4(%rbp)
jg     1195 <test+0x85>
mov    $0x2,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
js     117d <test+0x6d>
mov    %edi,%r14d
mov    $0x1,%ebx
mov    $0x1,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
xor    %edi,%edi
call   1030 <hash@plt>
test   %r14d,%r14d
je     1178 <test+0x68>
mov    %r14d,%ebp
neg    %ebp
nopl   0x0(%rax)
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1150 <test+0x40>
test   %r14d,%r14d
js     117d <test+0x6d>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x2,%edi
call   1030 <hash@plt>
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <hash@plt>

LLVM IR (-O0):
define void @test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = call i32 @hash(i32 1)
%8 = call i32 @hash(i32 0)
%9 = call i32 @hash(i32 2)
%10 = call i32 @hash(i32 0)
br label %11
11: ; preds = %6, %1
store i32 1, i32* %3
br label %12
12: ; preds = %20, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = call i32 @hash(i32 1)
%18 = load i32, i32* %3
%19 = call i32 @hash(i32 %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %12
23: ; preds = %12
%24 = load i32, i32* %2
%25 = icmp sle i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = call i32 @hash(i32 2)
%28 = call i32 @hash(i32 0)
br label %29
29: ; preds = %26, %23
ret void
}

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