#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char str[10];
  printf("input 9 character\n");
  scanf("%s", str);
  for (int i = 0; str[i] != '\0'; ++i) {
    printf("%c", str[i]);
  }
  printf("\n");
  puts(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11a2 <main+0x72>
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <main+0x3b>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x6(%rsp),%al
test   %al,%al
je     1173 <main+0x43>
lea    0x7(%rsp),%rbx
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x6(%rsp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [18 x i8] c"input 9 character\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %12, %2
%10 = call i32 @putchar(i32 10)
%11 = call i32 @puts(i8* %4)
ret i32 0
12: ; preds = %2, %12
%13 = phi i64 [ %17, %12 ], [ 0, %2 ]
%14 = phi i8 [ %19, %12 ], [ %7, %2 ]
%15 = sext i8 %14 to i32
%16 = call i32 @putchar(i32 %15)
%17 = add nuw i64 %13, 1
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %9, label %12
}