#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(void) {
  int number, sum;
  printf("ÇëÊäÈëÒ»¸öÈÎÒâµÄÕûÊý£º");
  scanf("%i", &number);
  while (number > 0) {
    sum += number % 10;
    number /= 10;
  };
  printf("¸ÃÕûÊýËùÓÐµÄÎ»ÉÏµÄÊý×ÖµÄºÍÎª£º%i\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    117b <main+0x5b>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x2d>
mov    -0xc(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    $0xcccccccd,%r8d
nopw   0x0(%rax,%rax,1)
mov    %eax,%ecx
mov    %eax,%eax
imul   %r8,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %ecx,%edx
sub    %edi,%edx
add    %edx,%esi
cmp    $0x9,%ecx
ja     1150 <main+0x30>
mov    %eax,0x4(%rsp)
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\92\C2\BB\C2\B8\C3\B6\C3\88\C3\8E\C3\92\C3\A2\C2\B5\C3\84\C3\95\C3\BB\C3\8A\C3\BD\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [64 x i8] c"\C2\B8\C3\83\C3\95\C3\BB\C3\8A\C3\BD\C3\8B\C3\B9\C3\93\C3\90\C2\B5\C3\84\C3\8E\C2\BB\C3\89\C3\8F\C2\B5\C3\84\C3\8A\C3\BD\C3\97\C3\96\C2\B5\C3\84\C2\BA\C3\8D\C3\8E\C2\AA\C2\A3\C2\BA%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
%12 = load i32, i32* %3
%13 = add nsw i32 %12, %11
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 10
store i32 %15, i32* %2
br label %6
16: ; preds = %6
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\92\C2\BB\C2\B8\C3\B6\C3\88\C3\8E\C3\92\C3\A2\C2\B5\C3\84\C3\95\C3\BB\C3\8A\C3\BD\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [64 x i8] c"\C2\B8\C3\83\C3\95\C3\BB\C3\8A\C3\BD\C3\8B\C3\B9\C3\93\C3\90\C2\B5\C3\84\C3\8E\C2\BB\C3\89\C3\8F\C2\B5\C3\84\C3\8A\C3\BD\C3\97\C3\96\C2\B5\C3\84\C2\BA\C3\8D\C3\8E\C2\AA\C2\A3\C2\BA%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ undef, %0 ]
%9 = phi i32 [ %12, %7 ], [ %5, %0 ]
%10 = urem i32 %9, 10
%11 = add nsw i32 %8, %10
%12 = udiv i32 %9, 10
%13 = icmp ult i32 %9, 10
br i1 %13, label %14, label %7
14: ; preds = %7
store i32 %12, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}