#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 *, long long *);
int main() {
  long long n;
  int count = 0;
  printf("Enter an integer: ");
  scanf("%lld", &n);
  while (n != 0) {
    if (n % 10 == 0) {
      ++count;
      n /= 10;
    } else
      break;
  }
  printf("Number of digits: %d", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11a1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1197 <main+0x77>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    119c <main+0x7c>
jmp    11a1 <main+0x81>
jmp    1154 <main+0x34>
mov    -0x14(%rbp),%esi
lea    0xe6d(%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   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
movabs $0x6666666666666667,%rdi
66 66 66
mov    %rcx,%rax
imul   %rdi
test   %rcx,%rcx
je     11cf <main+0xaf>
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %rcx,%rdx
sub    %rax,%rdx
jne    11cf <main+0xaf>
xor    %ebx,%ebx
nop
mov    %rcx,%rsi
mov    %rcx,%rax
imul   %rdi
add    $0x1,%ebx
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rcx
add    %rax,%rcx
add    $0xfffffffffffffff6,%rsi
mov    %rcx,%rax
imul   %rdi
cmp    $0xffffffffffffffec,%rsi
ja     11ca <main+0xaa>
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %rcx,%rdx
sub    %rax,%rdx
je     1180 <main+0x60>
mov    %rcx,0x8(%rsp)
lea    0xe42(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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