#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(void) {
  char a[80 + 1], b[80 + 1];
  int longa, longab;
  int i;
  printf("Introduce un texto (max %d cars.): ", 80);
  gets(a);
  printf("Introduce otro texto (max %d cars.): ", 80);
  gets(b);
  longa = strlen(a);
  longab = strlen(b);
  for (i = 0; i < longab; i++) {
    a[longa + i] = b[i];
  }
  a[longa + longab] = '\0';
  printf("Concatenacion de ambos: %s", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x50,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1050 <gets@plt>
lea    0xebf(%rip),%rdi
mov    $0x50,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc4(%rbp)
lea    -0xc0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc8(%rbp)
movl   $0x0,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
cmp    -0xc8(%rbp),%eax
jge    11ee <main+0xbe>
movslq -0xcc(%rbp),%rax
mov    -0xc0(%rbp,%rax,1),%cl
mov    -0xc4(%rbp),%eax
add    -0xcc(%rbp),%eax
cltq
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    11a8 <main+0x78>
mov    -0xc4(%rbp),%eax
add    -0xc8(%rbp),%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xb8,%rsp
lea    0xeb0(%rip),%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xeb6(%rip),%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x60(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    11b2 <main+0x72>
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rdi
mov    %ebp,%edx
lea    0x60(%rsp),%rsi
call   1050 <memcpy@plt>
add    %ebx,%ebp
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0xe88(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Introduce un texto (max %d cars.): \00"
@.str.1 = [38 x i8] c"Introduce otro texto (max %d cars.): \00"
@.str.2 = [27 x i8] c"Concatenacion de ambos: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca [81 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 80)
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 80)
%11 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
store i32 0, i32* %6
br label %17
17: ; preds = %31, %0
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %29
store i8 %25, i8* %30
br label %31
31: ; preds = %21
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %17
34: ; preds = %17
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = add nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %38
store i8 0, i8* %39
%40 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Introduce un texto (max %d cars.): \00"
@.str.1 = [38 x i8] c"Introduce otro texto (max %d cars.): \00"
@.str.2 = [27 x i8] c"Concatenacion de ambos: %s\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = alloca [81 x i8]
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 80)
%6 = call i32 @gets(i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 80)
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strlen(i8* %3)
%10 = call i32 @strlen(i8* %4)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%14 = sext i32 %9 to i64
%15 = getelementptr [81 x i8], [81 x i8]* %1, i64 0, i64 %14
%16 = zext i32 %10 to i64
br label %17
17: ; preds = %12, %0
%18 = add nsw i32 %10, %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}