#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 /*<<< orphan*/ contadigitos(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int d = 0, n = 0;
  printf("digite o valor de D: ");
  do {
    scanf("%d", &d);
  } while (d < 0);
  printf("digite o valor de N: ");
  scanf("%d", &n);
  printf("%n aparece %d vezes em %d", d, contadigitos(n, d), n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     115b <main+0x2b>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <contadigitos@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
mov    -0xc(%rbp),%ecx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%r14
lea    0x4(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
js     1160 <main+0x30>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%edi
mov    %ebx,%esi
call   1050 <contadigitos@plt>
mov    (%rsp),%ecx
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"digite o valor de D: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"digite o valor de N: \00"
@.str.3 = [26 x i8] c"%n aparece %d vezes em %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %7, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %5
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %5, label %10
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = call i32 @contadigitos(i32 %14, i32 %15)
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %16, i32 %17)
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [22 x i8] c"digite o valor de D: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"digite o valor de N: \00"
@.str.3 = [26 x i8] c"%n aparece %d vezes em %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 0
br i1 %9, label %6, label %10
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @contadigitos(i32 %14, i32 %13)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %15, i32 %16)
ret i32 0
}