#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 *);
char *string_copy(char *, char *);
int main(int argc, const char *argv[]) {
  char s[50], cs[50];
  printf("escreva a string:\n");
  scanf("%[^\n]s", s);
  printf("esta é a sua cópia:\n");
  printf("%s\n", string_copy(cs, s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1040 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <string_copy@plt>
mov    %rax,%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1050 <string_copy@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"escreva a string:\0A\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [23 x i8] c"esta \C3\A9 a sua c\C3\B3pia:\0A\00"
@.str.3 = [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 [50 x i8]
%7 = alloca [50 x i8]
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 [50 x i8], [50 x i8]* %6, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%14 = call i8* @string_copy(i8* %12, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@str = [18 x i8] c"escreva a string:\00"
@str.4 = [22 x i8] c"esta \C3\A9 a sua c\C3\B3pia:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%10 = call i8* @string_copy(i8* %6, i8* %5)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}