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


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    -0x8(%rbp),%eax
jg     1169 <test+0x59>
mov    $0x1,%edi
call   1030 <hash@plt>
mov    -0xc(%rbp),%edi
call   1030 <hash@plt>
mov    -0x8(%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>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    118f <test+0x7f>
mov    %edi,%r14d
add    $0x1,%r14d
mov    $0x1,%r15d
mov    $0x2,%r12d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
call   1030 <hash@plt>
mov    %ebx,%edi
call   1030 <hash@plt>
mov    %r15d,%edi
call   1030 <hash@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x2,%eax
jne    1150 <test+0x40>
add    $0x1,%r15d
lea    0x1(%r12),%eax
add    $0xffffffff,%ebp
cmp    %r14d,%r12d
mov    %eax,%r12d
jne    1140 <test+0x30>
pop    %rbx
pop    %r12
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* %3
%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* %4
%19 = call i32 @hash(i32 %18)
%20 = load i32, i32* %3
%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
ret void
}

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