#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 *, char *);
int main() {
  int i, length, prefix;
  char buf[200] = "";
  scanf("%s", buf);
  for (i = 0; buf[i] != '\0'; i++)
    ;
  length = i;
  prefix = length % 3;
  for (i = 0; i < prefix; i++)
    printf("%c", buf[i]);
  for (; buf[i] != '\0'; i++) {
    if (i > 0 && (i - prefix) % 3 == 0)
      printf(",");
    printf("%c", buf[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1197 <main+0x67>
jmp    1189 <main+0x59>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116f <main+0x3f>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e6 <main+0xb6>
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%esi
ff
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b2 <main+0x82>
jmp    11eb <main+0xbb>
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1257 <main+0x127>
cmpl   $0x0,-0x8(%rbp)
jle    122f <main+0xff>
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    122f <main+0xff>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%esi
ff
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11eb <main+0xbb>
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
lea    0xe74(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    $0xffffffff,%eax
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
add    $0xffffffff,%ebp
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    11b0 <main+0x90>
mov    %eax,%r14d
mov    $0xaaaaaaab,%eax
mov    %r14,%rcx
imul   %rax,%rcx
shr    $0x21,%rcx
lea    (%rcx,%rcx,2),%r15d
neg    %r15d
sub    %ebp,%r15d
jne    11e2 <main+0xc2>
xor    %ebx,%ebx
jmp    1215 <main+0xf5>
mov    %ebp,%r12d
neg    %r12d
imul   %r12,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%rax
sub    %rax,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1200 <main+0xe0>
mov    %r15d,%ebx
mov    (%rsp,%rbx,1),%al
test   %al,%al
je     1282 <main+0x162>
mov    $0xaaaaaaab,%ecx
imul   %r14,%rcx
shr    $0x21,%rcx
lea    (%rcx,%rcx,2),%r14d
add    %ebp,%r14d
jmp    1255 <main+0x135>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%rsp,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     1282 <main+0x162>
test   %rbx,%rbx
je     1240 <main+0x120>
lea    (%r14,%rbx,1),%ecx
imul   $0xaaaaaaab,%ecx,%ecx
add    $0x2aaaaaaa,%ecx
cmp    $0x55555554,%ecx
ja     1240 <main+0x120>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movzbl (%rsp,%rbx,1),%eax
jmp    1240 <main+0x120>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ %9, %4 ], [ 0, %0 ]
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = add nuw i64 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = trunc i64 %5 to i32
%12 = urem i32 %11, 3
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = zext i32 %12 to i64
br label %23
16: ; preds = %23
%17 = zext i32 %12 to i64
br label %18
18: ; preds = %10, %16
%19 = phi i64 [ %17, %16 ], [ 0, %10 ]
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %52, label %31
23: ; preds = %14, %23
%24 = phi i64 [ 0, %14 ], [ %29, %23 ]
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 @putchar(i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %15
br i1 %30, label %16, label %23
31: ; preds = %18, %44
%32 = phi i8 [ %50, %44 ], [ %21, %18 ]
%33 = phi i64 [ %48, %44 ], [ %19, %18 ]
%34 = phi i8* [ %49, %44 ], [ %20, %18 ]
%35 = icmp eq i64 %33, 0
br i1 %35, label %44, label %36
36: ; preds = %31
%37 = trunc i64 %33 to i32
%38 = sub nsw i32 %37, %12
%39 = srem i32 %38, 3
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i32 @putchar(i32 44)
%43 = load i8, i8* %34
br label %44
44: ; preds = %41, %36, %31
%45 = phi i8 [ %43, %41 ], [ %32, %36 ], [ %32, %31 ]
%46 = sext i8 %45 to i32
%47 = call i32 @putchar(i32 %46)
%48 = add nuw i64 %33, 1
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %52, label %31
52: ; preds = %44, %18
ret i32 0
}