#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 *, ...);
int strlen(char *);
int main() {
  int i, len;
  char line[1000000];
  while (gets(line)) {
    len = strlen(line);
    for (i = 0; i < len; i++) {
      if (line[i] == ' ')
        printf("%%20");
      else
        printf("%c", line[i]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4250,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xf4250(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     11e2 <main+0xb2>
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cf <main+0x9f>
movslq -0x8(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11a2 <main+0x72>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bc <main+0x8c>
movslq -0x8(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%esi
ff
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c1 <main+0x91>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x3e>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xf4250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf4248,%rsp
mov    %rsp,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     11c3 <main+0x83>
mov    %rsp,%r14
lea    0xe9b(%rip),%r15
jmp    1187 <main+0x47>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     11c3 <main+0x83>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1170 <main+0x30>
mov    %eax,%r12d
xor    %ebx,%ebx
jmp    11ae <main+0x6e>
nopw   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1170 <main+0x30>
movsbl (%rsp,%rbx,1),%edi
cmp    $0x20,%edi
jne    11a0 <main+0x60>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a5 <main+0x65>
xor    %eax,%eax
add    $0xf4248,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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