#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*/ expand(char *, char *);
int getchar();
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  int i, c;
  char s1[20], s2[1000];
  while ((c = getchar()) != '\n') {
    s1[i++] = c;
  }
  s1[i] = '\0';
  expand(s1, s2);
  printf("%s\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xa,%eax
je     1170 <main+0x40>
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
jmp    1142 <main+0x12>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <expand@plt>
lea    -0x410(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x410,%rsp
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1179 <main+0x49>
mov    %rsp,%rbx
movabs $0x100000000,%r15
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
add    %r15,%r14
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    $0xa,%eax
jne    1160 <main+0x30>
sar    $0x20,%r14
movb   $0x0,(%rsp,%r14,1)
mov    %rsp,%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <expand@plt>
lea    0xe6b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %9, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %3
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %3
%11 = trunc i32 %10 to i8
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %14
store i8 %11, i8* %15
br label %6
16: ; preds = %6
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%22 = call i32 @expand(i8* %20, i8* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @getchar()
%6 = icmp eq i32 %5, 10
br i1 %6, label %18, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %11, %7 ], [ 0, %0 ]
%9 = phi i32 [ %13, %7 ], [ %5, %0 ]
%10 = trunc i32 %9 to i8
%11 = add i64 %8, 1
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %8
store i8 %10, i8* %12
%13 = tail call i32 (...) @getchar()
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = shl i64 %11, 32
%17 = ashr exact i64 %16, 32
br label %18
18: ; preds = %15, %0
%19 = phi i64 [ 0, %0 ], [ %17, %15 ]
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @expand(i8* %3, i8* %4)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}