#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 */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ permuted(int, int);
int mult_permutation(int32_t i, int32_t max) {
  int32_t compare;
  for (int32_t c = 2; c <= max; c++) {
    compare = i * c;
    if (!permuted(i, compare))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<mult_permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     116e <mult_permutation+0x5e>
mov    -0x8(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <permuted@plt>
cmp    $0x0,%eax
jne    115b <mult_permutation+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1175 <mult_permutation+0x65>
jmp    1160 <mult_permutation+0x50>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1125 <mult_permutation+0x15>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_permutation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0x2,%esi
jl     1167 <mult_permutation+0x57>
mov    %esi,%r14d
mov    %edi,%r15d
lea    (%r15,%r15,1),%esi
call   1030 <permuted@plt>
test   %eax,%eax
je     1165 <mult_permutation+0x55>
lea    (%r15,%r15,2),%ebp
mov    $0x2,%ecx
nopl   (%rax)
mov    %ecx,%ebx
cmp    %ecx,%r14d
je     115b <mult_permutation+0x4b>
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <permuted@plt>
add    %r15d,%ebp
lea    0x1(%rbx),%ecx
test   %eax,%eax
jne    1140 <mult_permutation+0x30>
xor    %eax,%eax
cmp    %r14d,%ebx
setge  %al
jmp    1167 <mult_permutation+0x57>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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