#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*/ getch();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int count;
  char str1[30];
  char str2[30];
  printf("Digite uma string:");
  gets(str1);
  for (count = 0; str1[count] != '\0'; count++)
    str2[count] = str1[count];
  str2[count] = '\0';
  printf("Str2: ");
  for (count = 0; str2[count] != '\0'; count++)
    printf("%c", str2[count]);
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     118d <main+0x5d>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x2d>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11e2 <main+0xb2>
movslq -0x8(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ab <main+0x7b>
mov    $0x0,%al
call   1050 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rdi
call   1050 <gets@plt>
mov    0x20(%rsp),%al
test   %al,%al
je     1182 <main+0x42>
xor    %ecx,%ecx
nopl   0x0(%rax)
mov    %al,(%rsp,%rcx,1)
movzbl 0x21(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1170 <main+0x30>
mov    %ecx,%ebx
movb   $0x0,(%rsp,%rbx,1)
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     11b3 <main+0x73>
lea    0x1(%rsp),%rbx
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11a0 <main+0x60>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Digite uma string:\00"
@.str.1 = [7 x i8] c"Str2: \00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i8]
%4 = alloca [30 x i8]
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
store i32 0, i32* %2
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %8
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %8
26: ; preds = %8
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %31
31: ; preds = %45, %26
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %48
38: ; preds = %31
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %31
48: ; preds = %31
%49 = call i32 (...) @getch()
%50 = load i32, i32* %1
ret i32 %50
}

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