#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*/ *gets(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int strlen(char *);
int main(int argc, const char *argv[]) {
  char a[1000];
  int i, j, n;
  scanf("%d", &n);
  while (gets(a) != NULL) {
    if (strlen(a) > 0) {
      for (j = 0; j < strlen(a); j++)
        if (a[j] == ' ')
          a[j] = ',';
      printf("%s\n", a);
    }
  }
  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    0xea0(%rip),%rdi
lea    -0x40c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x400(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     1221 <main+0xe1>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jle    121c <main+0xdc>
movl   $0x0,-0x408(%rbp)
mov    -0x408(%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 -0x408(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11f0 <main+0xb0>
movslq -0x408(%rbp),%rax
movb   $0x2c,-0x400(%rbp,%rax,1)
2c
jmp    11f5 <main+0xb5>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    11a1 <main+0x61>
lea    -0x400(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
jmp    116c <main+0x2c>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0x10(%rsp),%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e1 <main+0xa1>
lea    0x10(%rsp),%r15
lea    0xe8b(%rip),%r14
jmp    1198 <main+0x58>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e1 <main+0xa1>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    118b <main+0x4b>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x40>
xor    %ebx,%ebx
jmp    11d3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1180 <main+0x40>
cmpb   $0x20,0x10(%rsp,%rbx,1)
jne    11c0 <main+0x80>
movb   $0x2c,0x10(%rsp,%rbx,1)
jmp    11c0 <main+0x80>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
br label %11
11: ; preds = %43, %2
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%13 = call i32* @gets(i8* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %15
store i32 0, i32* %8
br label %20
20: ; preds = %37, %19
%21 = load i32, i32* %8
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, 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* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %36
32: ; preds = %25
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 %34
store i8 44, i8* %35
br label %36
36: ; preds = %32, %25
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %20
40: ; preds = %20
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %15
br label %11
44: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%8 = call i32* @gets(i8* %5)
%9 = icmp eq i32* %8, null
br i1 %9, label %32, label %10
10: ; preds = %2, %29
%11 = call i32 @strlen(i8* %5)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %10
%14 = call i32 @strlen(i8* %5)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13, %22
%17 = phi i64 [ %23, %22 ], [ 0, %13 ]
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 32
br i1 %20, label %21, label %22
21: ; preds = %16
store i8 44, i8* %18
br label %22
22: ; preds = %16, %21
%23 = add nuw nsw i64 %17, 1
%24 = call i32 @strlen(i8* %5)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %16, label %27
27: ; preds = %22, %13
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %29
29: ; preds = %27, %10
%30 = call i32* @gets(i8* %5)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %10
32: ; preds = %29, %2
ret i32 0
}