#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 EXIT_SUCCESS;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(void) {
  static char string[30];
  int i, sum, number = 0, degree = 0;
  printf("½Ð¿é¤J¤@¥¿¾ã¼Æ¡G");
  fflush(stdin);
  gets(string);
  for (i = 0; i < strlen(string); i++)
    number += string[i] - '0';
  if (number % 9 == 0)
    degree = 1;
  else {
    printf("9-degree¬°¡G\n%d", degree);
    return 0;
  }
  while ((number % 9 == 0) && (number != 9)) {
    sum = 0;
    for (; number >= 1; number /= 10)
      sum += number % 10;
    number = sum;
    degree++;
  }
  printf("9-degree¬°¡G\n%d", degree);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0x2ed0(%rip),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0x2eb7(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11d1 <main+0x91>
movslq -0x8(%rbp),%rcx
lea    0x2e9a(%rip),%rax
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x4c>
mov    -0x10(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f1 <main+0xb1>
movl   $0x1,-0x14(%rbp)
jmp    120e <main+0xce>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ac <main+0x16c>
jmp    1213 <main+0xd3>
mov    -0x10(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    $0x0,%edx
mov    %al,-0x19(%rbp)
jne    1236 <main+0xf6>
cmpl   $0x9,-0x10(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1246 <main+0x106>
jmp    128f <main+0x14f>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     127b <main+0x13b>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%edx
mov    %edx,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    124d <main+0x10d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1213 <main+0xd3>
mov    -0x14(%rbp),%esi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0x2ee6(%rip),%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11e0 <main+0xa0>
xor    %r15d,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15,%r14,1),%eax
add    %eax,%ebx
add    $0xffffffd0,%ebx
add    $0x1,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r15
jl     1190 <main+0x50>
imul   $0x38e38e39,%ebx,%eax
add    $0xe38e38e,%eax
cmp    $0x1c71c71c,%eax
jbe    11d6 <main+0x96>
lea    0xe58(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125f <main+0x11f>
mov    $0x1,%esi
cmp    $0x9,%ebx
je     1248 <main+0x108>
mov    $0x1,%esi
mov    $0xcccccccd,%r8d
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
jle    1220 <main+0xe0>
mov    %ebx,%eax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %eax,%edx
imul   %r8,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %eax,%ecx
sub    %edi,%ecx
add    %ecx,%ebx
cmp    $0x9,%eax
mov    %edx,%eax
ja     1200 <main+0xc0>
jmp    1222 <main+0xe2>
nop
xor    %ebx,%ebx
add    $0x1,%esi
cmp    $0x9,%ebx
je     1248 <main+0x108>
movslq %ebx,%rax
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
je     11f0 <main+0xb0>
lea    0xdcf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.string = internal global [30 x i8] zeroinitializer
@.str = [30 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J\C2\A4@\C2\A5\C2\BF\C2\BE\C3\A3\C2\BC\C3\86\C2\A1G\00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"9-degree\C2\AC\C2\B0\C2\A1G\0A%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @gets(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.string, i64 0, i64 0))
store i32 0, i32* %2
br label %10
10: ; preds = %23, %0
%11 = load i32, i32* %2
%12 = call i32 @strlen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.string, i64 0, i64 0))
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [30 x i8], [30 x i8]* @main.string, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 48
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
br label %23
23: ; preds = %14
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %10
26: ; preds = %10
%27 = load i32, i32* %4
%28 = srem i32 %27, 9
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 1, i32* %5
br label %34
31: ; preds = %26
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %32)
store i32 0, i32* %1
br label %64
34: ; preds = %30
br label %35
35: ; preds = %56, %34
%36 = load i32, i32* %4
%37 = srem i32 %36, 9
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 9
br label %42
42: ; preds = %39, %35
%43 = phi i1 [ false, %35 ], [ %41, %39 ]
br i1 %43, label %44, label %60
44: ; preds = %42
store i32 0, i32* %3
br label %45
45: ; preds = %53, %44
%46 = load i32, i32* %4
%47 = icmp sge i32 %46, 1
br i1 %47, label %48, label %56
48: ; preds = %45
%49 = load i32, i32* %4
%50 = srem i32 %49, 10
%51 = load i32, i32* %3
%52 = add nsw i32 %51, %50
store i32 %52, i32* %3
br label %53
53: ; preds = %48
%54 = load i32, i32* %4
%55 = sdiv i32 %54, 10
store i32 %55, i32* %4
br label %45
56: ; preds = %45
%57 = load i32, i32* %3
store i32 %57, i32* %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %35
60: ; preds = %42
%61 = load i32, i32* %5
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = load i32, i32* @EXIT_SUCCESS
store i32 %63, i32* %1
br label %64
64: ; preds = %60, %31
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@main.string = internal global [30 x i8] zeroinitializer
@.str = [30 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J\C2\A4@\C2\A5\C2\BF\C2\BE\C3\A3\C2\BC\C3\86\C2\A1G\00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"9-degree\C2\AC\C2\B0\C2\A1G\0A%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @stdin
%3 = tail call i32 @fflush(i32 %2)
%4 = tail call i32 @gets(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.string, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.string, i64 0, i64 0))
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %0, %7
%8 = phi i64 [ %15, %7 ], [ 0, %0 ]
%9 = phi i32 [ %14, %7 ], [ 0, %0 ]
%10 = getelementptr inbounds [30 x i8], [30 x i8]* @main.string, i64 0, i64 %8
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = add i32 %9, -48
%14 = add i32 %13, %12
%15 = add nuw nsw i64 %8, 1
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.string, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %7, label %19
19: ; preds = %7
%20 = srem i32 %14, 9
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = icmp eq i32 %14, 9
br i1 %23, label %46, label %24
24: ; preds = %0, %22
%25 = phi i32 [ %14, %22 ], [ 0, %0 ]
br label %28
26: ; preds = %19
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %50
28: ; preds = %24, %39
%29 = phi i32 [ %41, %39 ], [ 1, %24 ]
%30 = phi i32 [ %40, %39 ], [ %25, %24 ]
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %28, %32
%33 = phi i32 [ %37, %32 ], [ %30, %28 ]
%34 = phi i32 [ %36, %32 ], [ 0, %28 ]
%35 = urem i32 %33, 10
%36 = add nuw nsw i32 %35, %34
%37 = udiv i32 %33, 10
%38 = icmp ult i32 %33, 10
br i1 %38, label %39, label %32
39: ; preds = %32, %28
%40 = phi i32 [ 0, %28 ], [ %36, %32 ]
%41 = add nuw nsw i32 %29, 1
%42 = srem i32 %40, 9
%43 = icmp eq i32 %42, 0
%44 = icmp ne i32 %40, 9
%45 = and i1 %44, %43
br i1 %45, label %28, label %46
46: ; preds = %39, %22
%47 = phi i32 [ 1, %22 ], [ %41, %39 ]
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @EXIT_SUCCESS
br label %50
50: ; preds = %46, %26
%51 = phi i32 [ %49, %46 ], [ 0, %26 ]
ret i32 %51
}