#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 */
scalar_t__ check_if_digit_in(int, long);
int check(long int num, long int product) {
  int d;
  int count = 0;
  while (num) {
    d = num % 10;
    if (check_if_digit_in(d, product))
      count++;
    else
      return 0;
  }
  if (count == 6)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117a <check+0x6a>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <check_if_digit_in@plt>
cmp    $0x0,%rax
je     1169 <check+0x59>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1175 <check+0x65>
movl   $0x0,-0x4(%rbp)
jmp    1197 <check+0x87>
jmp    1127 <check+0x17>
cmpl   $0x6,-0x20(%rbp)
jne    1190 <check+0x80>
movl   $0x1,-0x4(%rbp)
jmp    1197 <check+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     115f <check+0x4f>
mov    %rsi,%r14
mov    %rdi,%rbx
movabs $0x6666666666666667,%rcx
66 66 66
mov    %rdi,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x2,%rdx
add    %eax,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%eax
sub    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <check_if_digit_in@plt>
test   %rax,%rax
jne    1150 <check+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @check(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = srem i64 %0, 10
%6 = trunc i64 %5 to i32
br label %7
7: ; preds = %7, %4
%8 = tail call i64 @check_if_digit_in(i32 %6, i64 %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %7
10: ; preds = %7, %2
ret i32 0
}