#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 findMul(int);
int /*<<< orphan*/ isPrime(int);
int rotsArePrime(int n) {
  int num = n;
  int mul = findMul(n);
  int tmp = n;
  while (tmp) {
    if (!isPrime(n))
      return 0;
    int main = n / 10;
    int top = n % 10;
    n = main + top * mul;
    tmp /= 10;
  }
  return 1;
}


x86 assembly (clang, -O0):
<rotsArePrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <findMul@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a7 <rotsArePrime+0x87>
mov    -0x8(%rbp),%edi
call   1030 <isPrime@plt>
cmp    $0x0,%eax
jne    1169 <rotsArePrime+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11ae <rotsArePrime+0x8e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    1142 <rotsArePrime+0x22>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotsArePrime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <findMul@plt>
mov    $0x1,%r14d
test   %ebp,%ebp
je     1194 <rotsArePrime+0x74>
mov    %eax,%r15d
mov    %ebp,%ebx
nopl   (%rax)
mov    %ebp,%edi
call   1030 <isPrime@plt>
test   %eax,%eax
je     1191 <rotsArePrime+0x71>
movslq %ebp,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebp
imul   %r15d,%ebp
add    %eax,%ebp
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
add    $0x9,%eax
cmp    $0x12,%eax
ja     1140 <rotsArePrime+0x20>
jmp    1194 <rotsArePrime+0x74>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rotsArePrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = load i32, i32* %3
store i32 %9, i32* %4
%10 = load i32, i32* %3
%11 = call i32 @findMul(i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %3
store i32 %12, i32* %6
br label %13
13: ; preds = %21, %1
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i32, i32* %3
%18 = call i32 @isPrime(i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 0, i32* %2
br label %34
21: ; preds = %16
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 10
store i32 %23, i32* %7
%24 = load i32, i32* %3
%25 = srem i32 %24, 10
store i32 %25, i32* %8
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = load i32, i32* %5
%29 = mul nsw i32 %27, %28
%30 = add nsw i32 %26, %29
store i32 %30, i32* %3
%31 = load i32, i32* %6
%32 = sdiv i32 %31, 10
store i32 %32, i32* %6
br label %13
33: ; preds = %13
store i32 1, i32* %2
br label %34
34: ; preds = %33, %20
%35 = load i32, i32* %2
ret i32 %35
}

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