#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 *);
scalar_t__ mpz_divisible_ui_p(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
bool is_found(char *str) {
  mpz_t v;
  mpz_init_set_str(v, str, 10);
  if (str[0] != '0' && mpz_divisible_ui_p(v, 2011) && is_flippable(str)) {
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<is_found>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     1193 <is_found+0x63>
mov    -0x14(%rbp),%edi
mov    $0x7db,%esi
call   1030 <mpz_divisible_ui_p@plt>
cmp    $0x0,%rax
je     1193 <is_found+0x63>
mov    -0x10(%rbp),%rdi
call   1040 <is_flippable@plt>
cmp    $0x0,%rax
je     1193 <is_found+0x63>
movl   $0x1,-0x4(%rbp)
jmp    119a <is_found+0x6a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_found>:
push   %rbx
mov    %rdi,%rbx
mov    %rdi,%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
cmpb   $0x30,(%rbx)
je     116c <is_found+0x3c>
mov    $0x7db,%esi
call   1030 <mpz_divisible_ui_p@plt>
test   %rax,%rax
je     116c <is_found+0x3c>
mov    %rbx,%rdi
call   1040 <is_flippable@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     116c <is_found+0x3c>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_found(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 i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 48
br i1 %12, label %13, label %22
13: ; preds = %1
%14 = load i32, i32* %4
%15 = call i64 @mpz_divisible_ui_p(i32 %14, i32 2011)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i64 @is_flippable(i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %2
br label %23
22: ; preds = %17, %13, %1
store i32 0, i32* %2
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %2
ret i32 %24
}

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