#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(2);
    hash(1);
  };
  {
    hash(1);
    hash(3);
    hash(1);
  };
  {
    hash(1);
    hash(4);
    hash(1);
  };
  {
    hash(4);
    hash(4);
    hash(2);
  };
  for (i = 5; i <= M + 1; i++) {
    {
      hash(1);
      hash(i);
      hash(1);
    };
    for (j = 2;
         j <= (((i - 1) < 0) ? -((-(i - 1) + (2) - 1) / (2)) : (i - 1) / (2));
         j++) {
      {
        hash(2);
        hash(i);
        hash(j);
      };
    }
    if (i % 2 == 0) {
      {
        hash(4);
        hash(i);
        hash(i / 2);
      };
    }
  }
  for (i = M + 2; i <= 2 * M - 1; i++) {
    for (j = i - M;
         j <= (((i - 1) < 0) ? -((-(i - 1) + (2) - 1) / (2)) : (i - 1) / (2));
         j++) {
      {
        hash(2);
        hash(i);
        hash(j);
      };
    }
    if (i % 2 == 0) {
      {
        hash(4);
        hash(i);
        hash(i / 2);
      };
    }
  }
  i = 2 * M;
  {
    hash(4);
    hash(2 * M);
    hash(M);
  };
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     129b <test+0x18b>
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    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jge    1209 <test+0xf9>
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
xor    %eax,%eax
sub    %ecx,%eax
add    $0x2,%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    121a <test+0x10a>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jg     1250 <test+0x140>
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    11ce <test+0xbe>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1288 <test+0x178>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <hash@plt>
jmp    128d <test+0x17d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119a <test+0x8a>
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     138e <test+0x27e>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jge    12fc <test+0x1ec>
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
xor    %eax,%eax
sub    %ecx,%eax
add    $0x2,%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    130d <test+0x1fd>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jg     1343 <test+0x233>
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    12c1 <test+0x1b1>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    137b <test+0x26b>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%edi
call   1030 <hash@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <hash@plt>
jmp    1380 <test+0x270>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12a4 <test+0x194>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x4,%edi
call   1030 <hash@plt>
mov    -0x4(%rbp),%edi
shl    $0x1,%edi
call   1030 <hash@plt>
mov    -0x4(%rbp),%edi
call   1030 <hash@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x3,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%r15d
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    $0x2,%edi
call   1030 <hash@plt>
cmp    $0x4,%r14d
jge    1285 <test+0x175>
lea    0x2(%r14),%r13d
lea    (%r14,%r14,1),%r15d
cmp    %r15d,%r13d
jge    125d <test+0x14d>
mov    $0x1,%r12d
jmp    11d1 <test+0xc1>
nop
add    $0x1,%r13d
add    $0x1,%r12d
cmp    %r15d,%r13d
je     125d <test+0x14d>
mov    %r13d,%eax
sub    %r14d,%eax
test   %r13d,%r13d
jle    11f0 <test+0xe0>
lea    -0x1(%r13),%ebx
shr    %ebx
cmp    %ebx,%eax
jle    1207 <test+0xf7>
jmp    1230 <test+0x120>
nopl   0x0(%rax,%rax,1)
mov    $0x2,%ecx
sub    %r13d,%ecx
mov    %ecx,%ebx
shr    $0x1f,%ebx
add    %ecx,%ebx
sar    %ebx
neg    %ebx
cmp    %ebx,%eax
jg     1230 <test+0x120>
mov    %r12d,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %r13d,%edi
call   1030 <hash@plt>
mov    %ebp,%edi
call   1030 <hash@plt>
cmp    %ebx,%ebp
jl     1210 <test+0x100>
test   $0x1,%r13b
jne    11c0 <test+0xb0>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r13d,%edi
call   1030 <hash@plt>
mov    %r13d,%edi
shr    $0x1f,%edi
add    %r13d,%edi
sar    %edi
call   1030 <hash@plt>
jmp    11c0 <test+0xb0>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
mov    %r14d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <hash@plt>
mov    $0x5,%r12d
jmp    12a4 <test+0x194>
nopl   (%rax)
add    $0x1,%r12d
lea    0x1(%r15),%eax
cmp    %r14d,%r15d
mov    %eax,%r15d
je     11a6 <test+0x96>
mov    %r15d,%ebx
shr    %ebx
neg    %ebx
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %r12d,%edi
call   1030 <hash@plt>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    $0x2,%ebp
nopl   0x0(%rax)
mov    $0x2,%edi
call   1030 <hash@plt>
mov    %r12d,%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    $0x1,%eax
jne    12d0 <test+0x1c0>
test   $0x1,%r12b
jne    1290 <test+0x180>
mov    $0x4,%edi
call   1030 <hash@plt>
mov    %r12d,%edi
call   1030 <hash@plt>
mov    %r12d,%edi
shr    %edi
call   1030 <hash@plt>
jmp    1290 <test+0x180>

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 2)
%7 = call i32 @hash(i32 1)
%8 = call i32 @hash(i32 1)
%9 = call i32 @hash(i32 3)
%10 = call i32 @hash(i32 1)
%11 = call i32 @hash(i32 1)
%12 = call i32 @hash(i32 4)
%13 = call i32 @hash(i32 1)
%14 = call i32 @hash(i32 4)
%15 = call i32 @hash(i32 4)
%16 = call i32 @hash(i32 2)
store i32 5, i32* %3
br label %17
17: ; preds = %68, %1
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %71
22: ; preds = %17
%23 = call i32 @hash(i32 1)
%24 = load i32, i32* %3
%25 = call i32 @hash(i32 %24)
%26 = call i32 @hash(i32 1)
store i32 2, i32* %4
br label %27
27: ; preds = %53, %22
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 1
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %27
%33 = load i32, i32* %3
%34 = sub nsw i32 %33, 1
%35 = sub nsw i32 0, %34
%36 = add nsw i32 %35, 2
%37 = sub nsw i32 %36, 1
%38 = sdiv i32 %37, 2
%39 = sub nsw i32 0, %38
br label %44
40: ; preds = %27
%41 = load i32, i32* %3
%42 = sub nsw i32 %41, 1
%43 = sdiv i32 %42, 2
br label %44
44: ; preds = %40, %32
%45 = phi i32 [ %39, %32 ], [ %43, %40 ]
%46 = icmp sle i32 %28, %45
br i1 %46, label %47, label %56
47: ; preds = %44
%48 = call i32 @hash(i32 2)
%49 = load i32, i32* %3
%50 = call i32 @hash(i32 %49)
%51 = load i32, i32* %4
%52 = call i32 @hash(i32 %51)
br label %53
53: ; preds = %47
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %27
56: ; preds = %44
%57 = load i32, i32* %3
%58 = srem i32 %57, 2
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = call i32 @hash(i32 4)
%62 = load i32, i32* %3
%63 = call i32 @hash(i32 %62)
%64 = load i32, i32* %3
%65 = sdiv i32 %64, 2
%66 = call i32 @hash(i32 %65)
br label %67
67: ; preds = %60, %56
br label %68
68: ; preds = %67
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %17
71: ; preds = %17
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 2
store i32 %73, i32* %3
br label %74
74: ; preds = %125, %71
%75 = load i32, i32* %3
%76 = load i32, i32* %2
%77 = mul nsw i32 2, %76
%78 = sub nsw i32 %77, 1
%79 = icmp sle i32 %75, %78
br i1 %79, label %80, label %128
80: ; preds = %74
%81 = load i32, i32* %3
%82 = load i32, i32* %2
%83 = sub nsw i32 %81, %82
store i32 %83, i32* %4
br label %84
84: ; preds = %110, %80
%85 = load i32, i32* %4
%86 = load i32, i32* %3
%87 = sub nsw i32 %86, 1
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %97
89: ; preds = %84
%90 = load i32, i32* %3
%91 = sub nsw i32 %90, 1
%92 = sub nsw i32 0, %91
%93 = add nsw i32 %92, 2
%94 = sub nsw i32 %93, 1
%95 = sdiv i32 %94, 2
%96 = sub nsw i32 0, %95
br label %101
97: ; preds = %84
%98 = load i32, i32* %3
%99 = sub nsw i32 %98, 1
%100 = sdiv i32 %99, 2
br label %101
101: ; preds = %97, %89
%102 = phi i32 [ %96, %89 ], [ %100, %97 ]
%103 = icmp sle i32 %85, %102
br i1 %103, label %104, label %113
104: ; preds = %101
%105 = call i32 @hash(i32 2)
%106 = load i32, i32* %3
%107 = call i32 @hash(i32 %106)
%108 = load i32, i32* %4
%109 = call i32 @hash(i32 %108)
br label %110
110: ; preds = %104
%111 = load i32, i32* %4
%112 = add nsw i32 %111, 1
store i32 %112, i32* %4
br label %84
113: ; preds = %101
%114 = load i32, i32* %3
%115 = srem i32 %114, 2
%116 = icmp eq i32 %115, 0
br i1 %116, label %117, label %124
117: ; preds = %113
%118 = call i32 @hash(i32 4)
%119 = load i32, i32* %3
%120 = call i32 @hash(i32 %119)
%121 = load i32, i32* %3
%122 = sdiv i32 %121, 2
%123 = call i32 @hash(i32 %122)
br label %124
124: ; preds = %117, %113
br label %125
125: ; preds = %124
%126 = load i32, i32* %3
%127 = add nsw i32 %126, 1
store i32 %127, i32* %3
br label %74
128: ; preds = %74
%129 = load i32, i32* %2
%130 = mul nsw i32 2, %129
store i32 %130, i32* %3
%131 = call i32 @hash(i32 4)
%132 = load i32, i32* %2
%133 = mul nsw i32 2, %132
%134 = call i32 @hash(i32 %133)
%135 = load i32, i32* %2
%136 = call i32 @hash(i32 %135)
ret void
}

LLVM IR (-O2):
define void @test(i32 %0) {
%2 = tail call i32 @hash(i32 3)
%3 = tail call i32 @hash(i32 2)
%4 = tail call i32 @hash(i32 1)
%5 = tail call i32 @hash(i32 1)
%6 = tail call i32 @hash(i32 3)
%7 = tail call i32 @hash(i32 1)
%8 = tail call i32 @hash(i32 1)
%9 = tail call i32 @hash(i32 4)
%10 = tail call i32 @hash(i32 1)
%11 = tail call i32 @hash(i32 4)
%12 = tail call i32 @hash(i32 4)
%13 = tail call i32 @hash(i32 2)
%14 = icmp slt i32 %0, 4
br i1 %14, label %41, label %15
15: ; preds = %1, %37
%16 = phi i32 [ %39, %37 ], [ 4, %1 ]
%17 = phi i32 [ %38, %37 ], [ 5, %1 ]
%18 = lshr i32 %16, 1
%19 = tail call i32 @hash(i32 1)
%20 = tail call i32 @hash(i32 %17)
%21 = tail call i32 @hash(i32 1)
br label %22
22: ; preds = %15, %22
%23 = phi i32 [ %27, %22 ], [ 2, %15 ]
%24 = tail call i32 @hash(i32 2)
%25 = tail call i32 @hash(i32 %17)
%26 = tail call i32 @hash(i32 %23)
%27 = add nuw nsw i32 %23, 1
%28 = icmp eq i32 %23, %18
br i1 %28, label %29, label %22
29: ; preds = %22
%30 = and i32 %17, 1
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = tail call i32 @hash(i32 4)
%34 = tail call i32 @hash(i32 %17)
%35 = lshr i32 %17, 1
%36 = tail call i32 @hash(i32 %35)
br label %37
37: ; preds = %29, %32
%38 = add nuw nsw i32 %17, 1
%39 = add nuw nsw i32 %16, 1
%40 = icmp eq i32 %16, %0
br i1 %40, label %41, label %15
41: ; preds = %37, %1
%42 = add nsw i32 %0, 2
%43 = shl i32 %0, 1
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %73
45: ; preds = %41, %70
%46 = phi i32 [ %71, %70 ], [ %42, %41 ]
%47 = sub nsw i32 %46, %0
%48 = icmp slt i32 %46, 1
%49 = add nsw i32 %46, -1
%50 = lshr i32 %49, 1
%51 = sub i32 2, %46
%52 = sdiv i32 %51, -2
%53 = select i1 %48, i32 %52, i32 %50
%54 = icmp sgt i32 %47, %53
br i1 %54, label %62, label %55
55: ; preds = %45, %55
%56 = phi i32 [ %60, %55 ], [ %47, %45 ]
%57 = tail call i32 @hash(i32 2)
%58 = tail call i32 @hash(i32 %46)
%59 = tail call i32 @hash(i32 %56)
%60 = add nsw i32 %56, 1
%61 = icmp slt i32 %56, %53
br i1 %61, label %55, label %62
62: ; preds = %55, %45
%63 = and i32 %46, 1
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = tail call i32 @hash(i32 4)
%67 = tail call i32 @hash(i32 %46)
%68 = sdiv i32 %46, 2
%69 = tail call i32 @hash(i32 %68)
br label %70
70: ; preds = %62, %65
%71 = add i32 %46, 1
%72 = icmp eq i32 %71, %43
br i1 %72, label %73, label %45
73: ; preds = %70, %41
%74 = tail call i32 @hash(i32 4)
%75 = tail call i32 @hash(i32 %43)
%76 = tail call i32 @hash(i32 %0)
ret void
}