#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 num_digits(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int digit_included(int n, int m) {
  if (m < 10) {
    return n == m;
  }
  int m_len = num_digits(m);
  char digit_string[m_len + 1];
  snprintf(digit_string, m_len + 1, "%d", m);
  int i;
  for (i = 0; i < m_len; i++) {
    if (n + '0' == digit_string[i]) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<digit_included>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    114e <digit_included+0x2e>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ff <digit_included+0xdf>
mov    -0xc(%rbp),%edi
call   1040 <num_digits@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0xc(%rbp),%ecx
lea    0xe6e(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ea <digit_included+0xca>
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11d7 <digit_included+0xb7>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    11f8 <digit_included+0xd8>
jmp    11dc <digit_included+0xbc>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119e <digit_included+0x7e>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digit_included>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
cmp    $0x9,%esi
jg     1143 <digit_included+0x23>
xor    %eax,%eax
cmp    %r15d,%r14d
sete   %al
jmp    11ae <digit_included+0x8e>
mov    %r15d,%edi
call   1040 <num_digits@plt>
mov    %eax,%r12d
mov    %rsp,%r13
lea    0x1(%r12),%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe92(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1030 <snprintf@plt>
test   %r12d,%r12d
jle    11a2 <digit_included+0x82>
add    $0x30,%r14d
mov    %r12d,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rcx,1),%edx
cmp    %edx,%r14d
je     11a6 <digit_included+0x86>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1190 <digit_included+0x70>
xor    %eax,%eax
jmp    11ab <digit_included+0x8b>
mov    $0x1,%eax
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @digit_included(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = icmp eq i32 %14, %15
%17 = zext i1 %16 to i32
store i32 %17, i32* %3
br label %51
18: ; preds = %2
%19 = load i32, i32* %5
%20 = call i32 @num_digits(i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %7
%25 = alloca i8, i64 %23
store i64 %23, i64* %8
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %5
%29 = call i32 @snprintf(i8* %25, i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
store i32 0, i32* %9
br label %30
30: ; preds = %45, %18
%31 = load i32, i32* %9
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %48
34: ; preds = %30
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 48
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %25, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %36, %41
br i1 %42, label %43, label %44
43: ; preds = %34
store i32 1, i32* %3
store i32 1, i32* %10
br label %49
44: ; preds = %34
br label %45
45: ; preds = %44
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %30
48: ; preds = %30
store i32 0, i32* %3
store i32 1, i32* %10
br label %49
49: ; preds = %48, %43
%50 = load i8*, i8** %7
br label %51
51: ; preds = %49, %13
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @digit_included(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, 10
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = icmp eq i32 %0, %1
%6 = zext i1 %5 to i32
br label %29
7: ; preds = %2
%8 = tail call i32 @num_digits(i32 %1)
%9 = add nsw i32 %8, 1
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = call i32 @snprintf(i8* %12, i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%14 = add nsw i32 %0, 48
%15 = icmp sgt i32 %8, 0
br i1 %15, label %16, label %27
16: ; preds = %7
%17 = zext i32 %8 to i64
br label %20
18: ; preds = %20
%19 = icmp eq i64 %26, %17
br i1 %19, label %27, label %20
20: ; preds = %16, %18
%21 = phi i64 [ 0, %16 ], [ %26, %18 ]
%22 = getelementptr inbounds i8, i8* %12, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %14, %24
%26 = add nuw nsw i64 %21, 1
br i1 %25, label %27, label %18
27: ; preds = %20, %18, %7
%28 = phi i32 [ 0, %7 ], [ 0, %18 ], [ 1, %20 ]
br label %29
29: ; preds = %27, %4
%30 = phi i32 [ %6, %4 ], [ %28, %27 ]
ret i32 %30
}