#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 digit_count(int);
scalar_t__ find_rec(int *, int, int /*<<< orphan*/, int);
int to_int(int *, int);
int find(int num) {
  int count = digit_count(num);
  int array[count];
  return find_rec(array, count, 0, num) ? to_int(array, count) : 0;
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <digit_count@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x20(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%ecx
xor    %edx,%edx
call   1030 <find_rec@plt>
cmp    $0x0,%rax
je     1198 <find+0x68>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <to_int@plt>
mov    %eax,-0x24(%rbp)
jmp    11a2 <find+0x72>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11a2 <find+0x72>
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r12d
call   1040 <digit_count@plt>
mov    %eax,%r14d
mov    %eax,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %r15d,%r15d
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
mov    %r12d,%ecx
call   1030 <find_rec@plt>
test   %rax,%rax
je     1183 <find+0x53>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <to_int@plt>
mov    %eax,%r15d
mov    %r15d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @digit_count(i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i32, i64 %9
store i64 %9, i64* %5
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = call i64 @find_rec(i32* %11, i32 %12, i32 0, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %3
%18 = call i32 @to_int(i32* %11, i32 %17)
br label %20
19: ; preds = %1
br label %20
20: ; preds = %19, %16
%21 = phi i32 [ %18, %16 ], [ 0, %19 ]
%22 = load i8*, i8** %4
ret i32 %21
}

LLVM IR (-O2):
define i32 @find(i32 %0) {
%2 = tail call i32 @digit_count(i32 %0)
%3 = zext i32 %2 to i64
%4 = alloca i32, i64 %3
%5 = call i64 @find_rec(i32* %4, i32 %2, i32 0, i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @to_int(i32* %4, i32 %2)
br label %9
9: ; preds = %1, %7
%10 = phi i32 [ %8, %7 ], [ 0, %1 ]
ret i32 %10
}