#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 /*<<< orphan*/ mpz_t;

/* Variables and functions */
scalar_t__ is_flippable(char *);
int /*<<< orphan*/ mpz_cmp_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_mod_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
bool is_found_prime(char *str) {
  mpz_t v;
  mpz_init_set_str(v, str, 10);
  mpz_mod_ui(v, v, 2011);
  if (str[0] != '0' && !mpz_cmp_ui(v, 100) && is_flippable(str)) {
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<is_found_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x7db,%edx
call   1050 <mpz_mod_ui@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11b2 <is_found_prime+0x72>
mov    -0x14(%rbp),%edi
mov    $0x64,%esi
call   1060 <mpz_cmp_ui@plt>
cmp    $0x0,%eax
jne    11b2 <is_found_prime+0x72>
mov    -0x10(%rbp),%rdi
call   1030 <is_flippable@plt>
cmp    $0x0,%rax
je     11b2 <is_found_prime+0x72>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <is_found_prime+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_found_prime>:
push   %rbx
mov    %rdi,%rbx
mov    %rdi,%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
mov    $0x7db,%edx
call   1050 <mpz_mod_ui@plt>
cmpb   $0x30,(%rbx)
je     1185 <is_found_prime+0x45>
mov    $0x64,%esi
call   1060 <mpz_cmp_ui@plt>
test   %eax,%eax
jne    1185 <is_found_prime+0x45>
mov    %rbx,%rdi
call   1030 <is_flippable@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1185 <is_found_prime+0x45>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_found_prime(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i32, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @mpz_init_set_str(i32 %5, i8* %6, i32 10)
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = call i32 @mpz_mod_ui(i32 %8, i32 %9, i32 2011)
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 48
br i1 %15, label %16, label %25
16: ; preds = %1
%17 = load i32, i32* %4
%18 = call i32 @mpz_cmp_ui(i32 %17, i32 100)
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = call i64 @is_flippable(i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %2
br label %26
25: ; preds = %20, %16, %1
store i32 0, i32* %2
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @is_found_prime(i8* %0) {
%2 = tail call i32 @mpz_init_set_str(i32 undef, i8* %0, i32 10)
%3 = tail call i32 @mpz_mod_ui(i32 undef, i32 undef, i32 2011)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 48
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i32 @mpz_cmp_ui(i32 undef, i32 100)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i64 @is_flippable(i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %6, %1
br label %13
13: ; preds = %9, %12
%14 = phi i32 [ 0, %12 ], [ 1, %9 ]
ret i32 %14
}