#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*/ free(int *);
int *randomPermutation(int);
scalar_t__ takeStep(int, int);
int allAlphasRandomLoop(int i2) {
  int i;
  int *randomAlphas = randomPermutation(8);
  for (i = 0; i < 8; i++) {
    if (takeStep(randomAlphas[i], i2)) {
      free(randomAlphas);
      return 1;
    }
  }
  free(randomAlphas);
  return 0;
}


x86 assembly (clang, -O0):
<allAlphasRandomLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x8,%edi
call   1050 <randomPermutation@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    119f <allAlphasRandomLoop+0x6f>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x8(%rbp),%esi
call   1040 <takeStep@plt>
cmp    $0x0,%rax
je     118c <allAlphasRandomLoop+0x5c>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <allAlphasRandomLoop+0x7f>
jmp    1191 <allAlphasRandomLoop+0x61>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <allAlphasRandomLoop+0x20>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allAlphasRandomLoop>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x8,%edi
call   1050 <randomPermutation@plt>
mov    %rax,%rbx
mov    (%rax),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x4(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x8(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0xc(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x10(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x14(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x18(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
jne    11b9 <allAlphasRandomLoop+0x89>
mov    0x1c(%rbx),%edi
mov    %ebp,%esi
call   1040 <takeStep@plt>
test   %rax,%rax
je     11cf <allAlphasRandomLoop+0x9f>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebp,%ebp
jmp    11be <allAlphasRandomLoop+0x8e>

LLVM IR (-O0):
define i32 @allAlphasRandomLoop(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
%6 = call i32* @randomPermutation(i32 8)
store i32* %6, i32** %5
store i32 0, i32* %4
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = load i32, i32* %3
%17 = call i64 @takeStep(i32 %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = load i32*, i32** %5
%21 = call i32 @free(i32* %20)
store i32 1, i32* %2
br label %29
22: ; preds = %10
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %7
26: ; preds = %7
%27 = load i32*, i32** %5
%28 = call i32 @free(i32* %27)
store i32 0, i32* %2
br label %29
29: ; preds = %26, %19
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @allAlphasRandomLoop(i32 %0) {
%2 = tail call i32* @randomPermutation(i32 8)
%3 = load i32, i32* %2
%4 = tail call i64 @takeStep(i32 %3, i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %41
6: ; preds = %1
%7 = getelementptr inbounds i32, i32* %2, i64 1
%8 = load i32, i32* %7
%9 = tail call i64 @takeStep(i32 %8, i32 %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %41
11: ; preds = %6
%12 = getelementptr inbounds i32, i32* %2, i64 2
%13 = load i32, i32* %12
%14 = tail call i64 @takeStep(i32 %13, i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %41
16: ; preds = %11
%17 = getelementptr inbounds i32, i32* %2, i64 3
%18 = load i32, i32* %17
%19 = tail call i64 @takeStep(i32 %18, i32 %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %41
21: ; preds = %16
%22 = getelementptr inbounds i32, i32* %2, i64 4
%23 = load i32, i32* %22
%24 = tail call i64 @takeStep(i32 %23, i32 %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %41
26: ; preds = %21
%27 = getelementptr inbounds i32, i32* %2, i64 5
%28 = load i32, i32* %27
%29 = tail call i64 @takeStep(i32 %28, i32 %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %26
%32 = getelementptr inbounds i32, i32* %2, i64 6
%33 = load i32, i32* %32
%34 = tail call i64 @takeStep(i32 %33, i32 %0)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = getelementptr inbounds i32, i32* %2, i64 7
%38 = load i32, i32* %37
%39 = tail call i64 @takeStep(i32 %38, i32 %0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %36, %31, %26, %21, %16, %11, %6, %1
br label %42
42: ; preds = %36, %41
%43 = phi i32 [ 1, %41 ], [ 0, %36 ]
%44 = tail call i32 @free(i32* %2)
ret i32 %43
}