#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*/ itoa(int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int strlen(char *);
main() {
  int a, b;
  printf("input a,b\n");
  scanf("%d  %d", &a, &b);
  char c[100];
  int sum = a + b;
  itoa(sum, c, 10);
  int length = strlen(c);
  int i;
  for (i = 0; i < length; i++) {
    int static count = 0;
    printf("%c", c[i]);
    if (c[i] == '-')
      continue;
    count++;
    if ((count % 3 == 0) && i != length - 1)
      printf(",");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0xa,%edx
call   1060 <itoa@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    1233 <main+0xf3>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x2d,%eax
jne    11db <main+0x9b>
jmp    1225 <main+0xe5>
mov    0x2e63(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e5a(%rip)
mov    0x2e54(%rip),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1220 <main+0xe0>
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1220 <main+0xe0>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <main+0xe5>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11a1 <main+0x61>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
add    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
call   1070 <itoa@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11fc <main+0xac>
lea    -0x1(%rax),%r14d
mov    %eax,%r15d
xor    %ebx,%ebx
jmp    11b9 <main+0x69>
nop
add    $0x1,%rbx
cmp    %rbx,%r15
je     11fc <main+0xac>
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
cmpb   $0x2d,0x10(%rsp,%rbx,1)
je     11b0 <main+0x60>
mov    0x2e7c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e73(%rip)
imul   $0xaaaaaaab,%eax,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555554,%eax
ja     11b0 <main+0x60>
cmp    %rbx,%r14
je     11b0 <main+0x60>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d %d\00"
@main.count = internal unnamed_addr global i32 0
@str = [10 x i8] c"input a,b\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = add nsw i32 %10, %9
%12 = call i32 @itoa(i32 %11, i8* %8, i32 10)
%13 = call i32 @strlen(i8* %8)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %0
%16 = add nsw i32 %13, -1
%17 = zext i32 %16 to i64
%18 = zext i32 %13 to i64
br label %19
19: ; preds = %15, %36
%20 = phi i64 [ 0, %15 ], [ %37, %36 ]
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 @putchar(i32 %23)
%25 = load i8, i8* %21
%26 = icmp eq i8 %25, 45
br i1 %26, label %36, label %27
27: ; preds = %19
%28 = load i32, i32* @main.count
%29 = add nsw i32 %28, 1
store i32 %29, i32* @main.count
%30 = srem i32 %29, 3
%31 = icmp ne i32 %30, 0
%32 = icmp eq i64 %20, %17
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %36, label %34
34: ; preds = %27
%35 = call i32 @putchar(i32 44)
br label %36
36: ; preds = %27, %34, %19
%37 = add nuw nsw i64 %20, 1
%38 = icmp eq i64 %37, %18
br i1 %38, label %39, label %19
39: ; preds = %36, %0
ret i32 0
}