#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__ gets(char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int main() {
  char s[1002];
  int sum, i;
  while (gets(s)) {
    sum = 0;
    if (s[0] == '0' && strlen(s) == 1)
      break;
    for (i = 0; i < strlen(s); i++) {
      sum = sum * 10 + (s[i] - 48);
      sum = sum % 11;
    }
    if (sum == 0)
      printf("%s is a multiple of 11.\n", s);
    else
      printf("%s is not a multiple of 11.\n", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     1244 <main+0x114>
movl   $0x0,-0x3f4(%rbp)
movsbl -0x3f0(%rbp),%eax
cmp    $0x30,%eax
jne    118c <main+0x5c>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    118c <main+0x5c>
jmp    1244 <main+0x114>
movl   $0x0,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%eax
mov    %eax,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3fc(%rbp),%eax
cmp    %ecx,%eax
jge    1207 <main+0xd7>
imul   $0xa,-0x3f4(%rbp),%eax
movslq -0x3f8(%rbp),%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3f4(%rbp)
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1196 <main+0x66>
cmpl   $0x0,-0x3f4(%rbp)
jne    122c <main+0xfc>
lea    -0x3f0(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
jmp    123f <main+0x10f>
lea    -0x3f0(%rbp),%rsi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11fe <main+0xce>
mov    %rsp,%r12
lea    0xea5(%rip),%r14
lea    0xeb7(%rip),%r15
jmp    1185 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11fe <main+0xce>
cmpb   $0x30,(%rsp)
jne    1198 <main+0x68>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     11fe <main+0xce>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
test   %eax,%eax
jle    1170 <main+0x40>
xor    %r13d,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    (%rbx,%rbx,4),%eax
movsbl (%rsp,%r13,1),%ecx
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
movslq %eax,%rbx
imul   $0x2e8ba2e9,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
sub    %eax,%ebx
add    $0x1,%r13
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r13
jl     11b0 <main+0x80>
test   %ebx,%ebx
mov    %r15,%rdi
cmove  %r14,%rdi
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%s is a multiple of 11.\0A\00"
@.str.1 = [29 x i8] c"%s is not a multiple of 11.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1002 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %49, %0
%6 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%7 = call i64 @gets(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %50
9: ; preds = %5
store i32 0, i32* %3
%10 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 48
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %14
br label %50
19: ; preds = %14, %9
store i32 0, i32* %4
br label %20
20: ; preds = %37, %19
%21 = load i32, i32* %4
%22 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %40
25: ; preds = %20
%26 = load i32, i32* %3
%27 = mul nsw i32 %26, 10
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 48
%34 = add nsw i32 %27, %33
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = srem i32 %35, 11
store i32 %36, i32* %3
br label %37
37: ; preds = %25
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %20
40: ; preds = %20
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %44)
br label %49
46: ; preds = %40
%47 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%48 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %43
br label %5
50: ; preds = %18, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s is a multiple of 11.\0A\00"
@.str.1 = [29 x i8] c"%s is not a multiple of 11.\0A\00"
define i32 @main() {
%1 = alloca [1002 x i8]
%2 = getelementptr inbounds [1002 x i8], [1002 x i8]* %1, i64 0, i64 0
%3 = call i64 @gets(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %36, label %5
5: ; preds = %0, %31
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 48
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @strlen(i8* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %36, label %11
11: ; preds = %8, %5
%12 = call i32 @strlen(i8* %2)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %11, %14
%15 = phi i64 [ %24, %14 ], [ 0, %11 ]
%16 = phi i32 [ %23, %14 ], [ 0, %11 ]
%17 = mul nsw i32 %16, 10
%18 = getelementptr inbounds [1002 x i8], [1002 x i8]* %1, i64 0, i64 %15
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = add nsw i32 %17, -48
%22 = add nsw i32 %21, %20
%23 = srem i32 %22, 11
%24 = add nuw nsw i64 %15, 1
%25 = call i32 @strlen(i8* %2)
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %14, label %28
28: ; preds = %14
%29 = icmp eq i32 %23, 0
%30 = select i1 %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0)
br label %31
31: ; preds = %28, %11
%32 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %11 ], [ %30, %28 ]
%33 = call i32 @printf(i8* %32, i8* %2)
%34 = call i64 @gets(i8* %2)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %5
36: ; preds = %31, %8, %0
ret i32 0
}