#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int i, sum;
  char number[1000] = {0};
  fflush(stdin);
  while (gets(number) != NULL && number[0] != '0') {
    for (i = 0, sum = 0; i < strlen(number); i++) {
      sum = sum * 10 + number[i] - '0';
      sum %= 17;
    }
    if (!sum)
      printf("1\n");
    else
      printf("0\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x400(%rbp),%rdi
call   1060 <gets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x401(%rbp)
je     11be <main+0x6e>
movsbl -0x400(%rbp),%eax
cmp    $0x30,%eax
setne  %al
mov    %al,-0x401(%rbp)
mov    -0x401(%rbp),%al
test   $0x1,%al
jne    11d1 <main+0x81>
jmp    1264 <main+0x114>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x408(%rbp),%eax
cmp    %ecx,%eax
jge    1238 <main+0xe8>
imul   $0xa,-0x18(%rbp),%eax
movslq -0x14(%rbp),%rcx
movsbl -0x400(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x11,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11df <main+0x8f>
cmpl   $0x0,-0x18(%rbp)
jne    1253 <main+0x103>
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
jmp    125f <main+0x10f>
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
jmp    118a <main+0x3a>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rbx
mov    $0x3e8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     1236 <main+0xe6>
cmpb   $0x30,(%rsp)
je     1236 <main+0xe6>
mov    %rsp,%r12
lea    0xe5b(%rip),%r14
lea    0xe56(%rip),%r15
nopl   0x0(%rax)
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
test   %eax,%eax
jle    121a <main+0xca>
xor    %r13d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rbx,%rbx,4),%eax
movsbl (%rsp,%r13,1),%ecx
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
movslq %eax,%rbx
imul   $0x78787879,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
mov    %eax,%ecx
shl    $0x4,%ecx
add    %eax,%ecx
sub    %ecx,%ebx
add    $0x1,%r13
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r13
jl     11d0 <main+0x80>
test   %ebx,%ebx
mov    %r15,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     1236 <main+0xe6>
cmpb   $0x30,(%rsp)
jne    11b0 <main+0x60>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@str = [2 x i8] c"1\00"
@str.2 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = tail call i32 @fflush(i32 %5)
%7 = call i32* @gets(i8* %4)
%8 = icmp ne i32* %7, null
%9 = load i8, i8* %4
%10 = icmp ne i8 %9, 48
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %40
12: ; preds = %2, %32
%13 = call i32 @strlen(i8* %4)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %12, %15
%16 = phi i64 [ %25, %15 ], [ 0, %12 ]
%17 = phi i32 [ %24, %15 ], [ 0, %12 ]
%18 = mul nsw i32 %17, 10
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %16
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = add nsw i32 %18, -48
%23 = add nsw i32 %22, %21
%24 = srem i32 %23, 17
%25 = add nuw nsw i64 %16, 1
%26 = call i32 @strlen(i8* %4)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %15, label %29
29: ; preds = %15
%30 = icmp eq i32 %24, 0
%31 = select i1 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.2, i64 0, i64 0)
br label %32
32: ; preds = %29, %12
%33 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %12 ], [ %31, %29 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
%35 = call i32* @gets(i8* %4)
%36 = icmp ne i32* %35, null
%37 = load i8, i8* %4
%38 = icmp ne i8 %37, 48
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %12, label %40
40: ; preds = %32, %2
ret i32 0
}