#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 */
scalar_t__ getInputValue(char);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int strlen(char *);
int main() {
  char input[1005];
  int i = 0;
  while (1) {
    gets(input);
    if (strlen(input) == 1 && input[0] == '0')
      break;
    int totalSum = 0;
    for (i = 0; i < strlen(input); i++) {
      totalSum += getInputValue(input[i]);
    }
    i = 1;
    while (totalSum > 9) {
      int temp = 0;
      i++;
      while (totalSum > 0) {
        temp += totalSum % 10;
        totalSum /= 10;
      }
      totalSum = temp;
    }
    if (totalSum % 9 == 0) {
      printf("%s is a multiple of 9 and has 9-degree %d.\n", input, i);
    } else {
      printf("%s is not a multiple of 9.\n", input);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x404(%rbp)
lea    -0x400(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1192 <main+0x52>
movsbl -0x400(%rbp),%eax
cmp    $0x30,%eax
jne    1192 <main+0x52>
jmp    12db <main+0x19b>
movl   $0x0,-0x408(%rbp)
movl   $0x0,-0x404(%rbp)
mov    -0x404(%rbp),%eax
mov    %eax,-0x410(%rbp)
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x410(%rbp),%eax
cmp    %ecx,%eax
jge    1209 <main+0xc9>
movslq -0x404(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%edi
ff
call   1060 <getInputValue@plt>
mov    %rax,%rcx
movslq -0x408(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x408(%rbp)
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    11a6 <main+0x66>
movl   $0x1,-0x404(%rbp)
cmpl   $0x9,-0x408(%rbp)
jle    128a <main+0x14a>
movl   $0x0,-0x40c(%rbp)
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
cmpl   $0x0,-0x408(%rbp)
jle    1279 <main+0x139>
mov    -0x408(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0x40c(%rbp),%edx
mov    %edx,-0x40c(%rbp)
mov    -0x408(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x408(%rbp)
jmp    1239 <main+0xf9>
mov    -0x40c(%rbp),%eax
mov    %eax,-0x408(%rbp)
jmp    1213 <main+0xd3>
mov    -0x408(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12c1 <main+0x181>
lea    -0x400(%rbp),%rsi
mov    -0x404(%rbp),%edx
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d6 <main+0x196>
lea    -0x400(%rbp),%rsi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115c <main+0x1c>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1173 <main+0x33>
cmpb   $0x30,(%rsp)
je     1275 <main+0x135>
mov    %rsp,%r12
mov    $0xcccccccd,%r13d
lea    0xea9(%rip),%r14
lea    0xe76(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1240 <main+0x100>
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%edi
call   1060 <getInputValue@plt>
add    %eax,%ebp
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11b0 <main+0x70>
mov    $0x1,%edx
cmp    $0xa,%ebp
jl     1212 <main+0xd2>
mov    $0x1,%edx
nopl   (%rax)
mov    %ebp,%eax
add    $0x1,%edx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %eax,%ecx
imul   %r13,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %eax,%edi
sub    %esi,%edi
add    %edi,%ebp
cmp    $0xa,%eax
mov    %ecx,%eax
jae    11f0 <main+0xb0>
cmp    $0xa,%ebp
jae    11e0 <main+0xa0>
imul   $0x38e38e39,%ebp,%eax
add    $0xe38e38e,%eax
cmp    $0x1c71c71c,%eax
jbe    1245 <main+0x105>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1252 <main+0x112>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <gets@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1190 <main+0x50>
cmpb   $0x30,(%rsp)
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"%s is a multiple of 9 and has 9-degree %d.\0A\00"
@.str.1 = [28 x i8] c"%s is not a multiple of 9.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1005 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %0, %67
%7 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 48
br i1 %16, label %17, label %18
17: ; preds = %12
br label %68
18: ; preds = %12, %6
store i32 0, i32* %4
store i32 0, i32* %3
br label %19
19: ; preds = %34, %18
%20 = load i32, i32* %3
%21 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %37
24: ; preds = %19
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i64 @getInputValue(i8 signext %28)
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = add nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %4
br label %34
34: ; preds = %24
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %19
37: ; preds = %19
store i32 1, i32* %3
br label %38
38: ; preds = %54, %37
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 9
br i1 %40, label %41, label %56
41: ; preds = %38
store i32 0, i32* %5
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %44
44: ; preds = %47, %41
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i32, i32* %4
%49 = srem i32 %48, 10
%50 = load i32, i32* %5
%51 = add nsw i32 %50, %49
store i32 %51, i32* %5
%52 = load i32, i32* %4
%53 = sdiv i32 %52, 10
store i32 %53, i32* %4
br label %44
54: ; preds = %44
%55 = load i32, i32* %5
store i32 %55, i32* %4
br label %38
56: ; preds = %38
%57 = load i32, i32* %4
%58 = srem i32 %57, 9
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%62 = load i32, i32* %3
%63 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %61, i32 %62)
br label %67
64: ; preds = %56
%65 = getelementptr inbounds [1005 x i8], [1005 x i8]* %2, i64 0, i64 0
%66 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %60
br label %6
68: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"%s is a multiple of 9 and has 9-degree %d.\0A\00"
@.str.1 = [28 x i8] c"%s is not a multiple of 9.\0A\00"
define i32 @main() {
%1 = alloca [1005 x i8]
%2 = getelementptr inbounds [1005 x i8], [1005 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp eq i32 %4, 1
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 48
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %56, label %9
9: ; preds = %0, %49
%10 = call i32 @strlen(i8* %2)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %14, label %44
12: ; preds = %14
%13 = icmp sgt i32 %21, 9
br i1 %13, label %28, label %39
14: ; preds = %9, %14
%15 = phi i64 [ %22, %14 ], [ 0, %9 ]
%16 = phi i32 [ %21, %14 ], [ 0, %9 ]
%17 = getelementptr inbounds [1005 x i8], [1005 x i8]* %1, i64 0, i64 %15
%18 = load i8, i8* %17
%19 = call i64 @getInputValue(i8 signext %18)
%20 = trunc i64 %19 to i32
%21 = add i32 %16, %20
%22 = add nuw nsw i64 %15, 1
%23 = call i32 @strlen(i8* %2)
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %14, label %12
26: ; preds = %32
%27 = icmp ugt i32 %36, 9
br i1 %27, label %28, label %39
28: ; preds = %12, %26
%29 = phi i32 [ %36, %26 ], [ %21, %12 ]
%30 = phi i32 [ %31, %26 ], [ 1, %12 ]
%31 = add nuw nsw i32 %30, 1
br label %32
32: ; preds = %28, %32
%33 = phi i32 [ %36, %32 ], [ 0, %28 ]
%34 = phi i32 [ %37, %32 ], [ %29, %28 ]
%35 = urem i32 %34, 10
%36 = add nuw nsw i32 %33, %35
%37 = udiv i32 %34, 10
%38 = icmp ult i32 %34, 10
br i1 %38, label %26, label %32
39: ; preds = %26, %12
%40 = phi i32 [ 1, %12 ], [ %31, %26 ]
%41 = phi i32 [ %21, %12 ], [ %36, %26 ]
%42 = srem i32 %41, 9
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %9, %39
%45 = phi i32 [ %40, %39 ], [ 1, %9 ]
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %45)
br label %49
47: ; preds = %39
%48 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %49
49: ; preds = %47, %44
%50 = call i32 @gets(i8* %2)
%51 = call i32 @strlen(i8* %2)
%52 = icmp eq i32 %51, 1
%53 = load i8, i8* %2
%54 = icmp eq i8 %53, 48
%55 = select i1 %52, i1 %54, i1 false
br i1 %55, label %56, label %9
56: ; preds = %49, %0
ret i32 0
}