#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*/ scanf(char *, char *);
int main(void) {
  char *str1, *str2, lida[10], copiada[10];
  printf("\nDigite uma string de no máximo %i caracteres:\n", 10);
  scanf("%[^\n]s", lida);
  lida[10] = '\0';
  str1 = lida;
  str2 = copiada;
  while (*(str2++) = *(str1++))
    ;
  printf("\nA string lida:\n\"%s\"\n", lida);
  printf("\nA string copiada:\n\"%s\"\n", copiada);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xee4(%rip),%rdi
call   1040 <scanf@plt>
movb   $0x0,-0x18(%rbp)
lea    -0x22(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x2c(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     1195 <main+0x75>
jmp    1166 <main+0x46>
lea    -0x22(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2c(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movb   $0x0,0x16(%rsp)
movzbl 0xc(%rsp,%rbx,1),%eax
mov    %al,0x16(%rsp,%rbx,1)
add    $0x1,%rbx
test   %al,%al
jne    1150 <main+0x30>
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x16(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\0ADigite uma string de no m\C3\A1ximo %i caracteres:\0A\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [22 x i8] c"\0AA string lida:\0A\22%s\22\0A\00"
@.str.3 = [25 x i8] c"\0AA string copiada:\0A\22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 10)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 10
store i8 0, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8* %10, i8** %2
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8* %11, i8** %3
br label %12
12: ; preds = %19, %0
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %2
%15 = load i8, i8* %13
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
store i8 %15, i8* %16
%18 = icmp ne i8 %15, 0
br i1 %18, label %19, label %20
19: ; preds = %12
br label %12
20: ; preds = %12
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"\0ADigite uma string de no m\C3\A1ximo %i caracteres:\0A\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [22 x i8] c"\0AA string lida:\0A\22%s\22\0A\00"
@.str.3 = [25 x i8] c"\0AA string copiada:\0A\22%s\22\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 10)
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 10
store i8 0, i8* %7
br label %8
8: ; preds = %8, %0
%9 = phi i8* [ %3, %0 ], [ %11, %8 ]
%10 = phi i8* [ %4, %0 ], [ %13, %8 ]
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = load i8, i8* %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %12, i8* %10
%14 = icmp eq i8 %12, 0
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}