#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 checkPalindrome(char *);
int /*<<< orphan*/ concatenateStr(char *, char *, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char str1[100], str2[100], *concat = NULL;
  int len1, len2, len, ret = 0;
  fgets(str1, 100, stdin);
  len1 = strlen(str1);
  len1--;
  str1[len1] = '\0';
  fgets(str2, 100, stdin);
  len2 = strlen(str2);
  len2--;
  str2[len2] = '\0';
  len = len1 + len2;
  concat = malloc(len);
  concatenateStr(str1, str2, concat);
  printf("\nconcatenated : %s\n", concat);
  ret = checkPalindrome(concat);
  if (ret)
    printf("\nstring is palindrome\n");
  else
    printf("\nString is not palindrome\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0xe8(%rbp)
movl   $0x0,-0xf8(%rbp)
lea    -0x70(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1070 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xec(%rbp)
mov    -0xec(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xec(%rbp)
movslq -0xec(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0xe0(%rbp),%rdi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1070 <fgets@plt>
lea    -0xe0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xf0(%rbp)
mov    -0xf0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xf0(%rbp)
movslq -0xf0(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
mov    -0xec(%rbp),%eax
add    -0xf0(%rbp),%eax
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xe8(%rbp),%rdx
call   1040 <concatenateStr@plt>
mov    -0xe8(%rbp),%rsi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xe8(%rbp),%rdi
call   1030 <checkPalindrome@plt>
mov    %eax,-0xf8(%rbp)
cmpl   $0x0,-0xf8(%rbp)
je     1294 <main+0x134>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12a2 <main+0x142>
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    0x2e65(%rip),%r15
mov    (%r15),%edx
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
movslq %eax,%rbx
movb   $0x0,0x6f(%rsp,%rbx,1)
add    $0xffffffffffffffff,%rbx
mov    (%r15),%edx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
movslq %eax,%rdi
movb   $0x0,-0x1(%rsp,%rdi,1)
add    $0xffffffffffffffff,%rdi
add    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <concatenateStr@plt>
lea    0xe0e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <checkPalindrome@plt>
test   %eax,%eax
lea    0xe07(%rip),%rax
lea    0xe1a(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [20 x i8] c"\0Aconcatenated : %s\0A\00"
@.str.1 = [23 x i8] c"\0Astring is palindrome\0A\00"
@.str.2 = [27 x i8] c"\0AString is not palindrome\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %4
store i32 0, i32* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 100, i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = add nsw i32 %14, -1
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 100, i32 %20)
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = add nsw i32 %24, -1
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = add nsw i32 %29, %30
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = call i8* @malloc(i32 %32)
store i8* %33, i8** %4
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%36 = load i8*, i8** %4
%37 = call i32 @concatenateStr(i8* %34, i8* %35, i8* %36)
%38 = load i8*, i8** %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %4
%41 = call i32 @checkPalindrome(i8* %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %48
46: ; preds = %0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [20 x i8] c"\0Aconcatenated : %s\0A\00"
@str = [26 x i8] c"\0AString is not palindrome\00"
@str.3 = [22 x i8] c"\0Astring is palindrome\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 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 100, i32 %5)
%7 = call i32 @strlen(i8* %3)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %4, i32 100, i32 %11)
%13 = call i32 @strlen(i8* %4)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %15
store i8 0, i8* %16
%17 = add nsw i32 %14, %8
%18 = call i8* @malloc(i32 %17)
%19 = call i32 @concatenateStr(i8* %3, i8* %4, i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18)
%21 = call i32 @checkPalindrome(i8* %18)
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0)
%24 = call i32 @puts(i8* dereferenceable(1) %23)
ret i32 0
}