#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*/ clr();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ gotoxy(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char first[100], second[100], *tmp;
  clr();
  gotoxy(10, 10);
  printf("Enter the first string\n");
  gotoxy(10, 11);
  gets(first);
  clr();
  gotoxy(10, 10);
  printf("Enter the second string\n");
  gotoxy(10, 11);
  gets(second);
  tmp = (char *)malloc((strlen(first) + 1) * sizeof(char));
  strcpy(tmp, first);
  strcpy(first, second);
  strcpy(second, tmp);
  clr();
  gotoxy(10, 10);
  printf("First string: %s\n", first);
  gotoxy(10, 11);
  printf("Second string: %s\n", second);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <clr@plt>
mov    $0xa,%esi
mov    %esi,%edi
call   1090 <gotoxy@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   1090 <gotoxy@plt>
lea    -0x70(%rbp),%rdi
call   1070 <gets@plt>
mov    $0x0,%al
call   1040 <clr@plt>
mov    $0xa,%esi
mov    %esi,%edi
call   1090 <gotoxy@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   1090 <gotoxy@plt>
lea    -0xe0(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    $0x0,%al
call   1040 <clr@plt>
mov    $0xa,%esi
mov    %esi,%edi
call   1090 <gotoxy@plt>
lea    -0x70(%rbp),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   1090 <gotoxy@plt>
lea    -0xe0(%rbp),%rsi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
xor    %eax,%eax
call   1040 <clr@plt>
mov    $0xa,%edi
mov    $0xa,%esi
call   10a0 <gotoxy@plt>
lea    0xe7c(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   10a0 <gotoxy@plt>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
call   1080 <gets@plt>
xor    %eax,%eax
call   1040 <clr@plt>
mov    $0xa,%edi
mov    $0xa,%esi
call   10a0 <gotoxy@plt>
lea    0xe55(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   10a0 <gotoxy@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <gets@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1040 <clr@plt>
mov    $0xa,%edi
mov    $0xa,%esi
call   10a0 <gotoxy@plt>
lea    0xda9(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
mov    $0xb,%esi
call   10a0 <gotoxy@plt>
lea    0xd9b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter the first string\0A\00"
@.str.1 = [25 x i8] c"Enter the second string\0A\00"
@.str.2 = [18 x i8] c"First string: %s\0A\00"
@.str.3 = [19 x i8] c"Second string: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 (...) @clr()
%6 = call i32 @gotoxy(i32 10, i32 10)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gotoxy(i32 10, i32 11)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 (...) @clr()
%12 = call i32 @gotoxy(i32 10, i32 10)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @gotoxy(i32 10, i32 11)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i32 @gets(i8* %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%32 = load i8*, i8** %4
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = call i32 (...) @clr()
%35 = call i32 @gotoxy(i32 10, i32 10)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = call i32 @gotoxy(i32 10, i32 11)
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %39)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [18 x i8] c"First string: %s\0A\00"
@.str.3 = [19 x i8] c"Second string: %s\0A\00"
@str = [23 x i8] c"Enter the first string\00"
@str.4 = [24 x i8] c"Enter the second string\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @clr()
%6 = tail call i32 @gotoxy(i32 10, i32 10)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @gotoxy(i32 10, i32 11)
%9 = call i32 @gets(i8* %3)
%10 = call i32 (...) @clr()
%11 = call i32 @gotoxy(i32 10, i32 10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
%13 = call i32 @gotoxy(i32 10, i32 11)
%14 = call i32 @gets(i8* %4)
%15 = call i32 @strlen(i8* %3)
%16 = add nsw i32 %15, 1
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
%19 = call i32 @strcpy(i8* %18, i8* %3)
%20 = call i32 @strcpy(i8* %3, i8* %4)
%21 = call i32 @strcpy(i8* %4, i8* %18)
%22 = call i32 (...) @clr()
%23 = call i32 @gotoxy(i32 10, i32 10)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%25 = call i32 @gotoxy(i32 10, i32 11)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}