#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, c, r, i;
  printf("n=");
  scanf("%d", &n);
  printf("c=");
  scanf("%d", &c);
  i = 0;
  while (n > 0) {
    r = n % 10;
    if (r == c) {
      i++;
    }
    n = n / 10;
  }
  printf("%d", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11b2 <main+0x92>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    119f <main+0x7f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1172 <main+0x52>
mov    -0x14(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec8(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
jle    11a8 <main+0x88>
xor    %ebx,%ebx
mov    0x4(%rsp),%ecx
mov    $0xcccccccd,%r8d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%edx
mov    %eax,%eax
imul   %r8,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %edx,%esi
sub    %edi,%esi
xor    %edi,%edi
cmp    %ecx,%esi
sete   %dil
add    %edi,%ebx
cmp    $0x9,%edx
ja     1180 <main+0x60>
mov    %eax,(%rsp)
lea    0xe54(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"n=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"c=\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %5
br label %10
10: ; preds = %22, %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 10
store i32 %24, i32* %2
br label %10
25: ; preds = %10
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"n=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"c=\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %0
%12 = load i32, i32* %2
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ 0, %11 ], [ %19, %13 ]
%15 = phi i32 [ %9, %11 ], [ %20, %13 ]
%16 = urem i32 %15, 10
%17 = icmp eq i32 %16, %12
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %14, %18
%20 = udiv i32 %15, 10
%21 = icmp ult i32 %15, 10
br i1 %21, label %22, label %13
22: ; preds = %13
store i32 %20, i32* %1
br label %23
23: ; preds = %22, %0
%24 = phi i32 [ %19, %22 ], [ 0, %0 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}