#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int main() {
  char str1[256] = {0};
  char str2[256] = {0};
  char *buffy = NULL;
  int len1 = 0;
  int len2 = 0;
  printf("Type in a string: ");
  scanf("%s", str1);
  rewind(stdin);
  printf("Type in another string: ");
  scanf("%s", str2);
  len1 = strlen(str1);
  len2 = strlen(str2);
  buffy = (char *)malloc(sizeof(char) * (len1 + len2 + 1));
  if (!buffy)
    return 0;
  sprintf(buffy, "%s", str1);
  strcat(buffy, str2);
  printf("%s\n", buffy);
  if (strcmp(str1, str2) == 0)
    printf("%s is equal to %s\n", str1, str2);
  else
    printf("%s is not equal to %s\n", str1, str2);
  if (strstr(str2, str1))
    printf("%s is contained within %s is TRUE!\n", str1, str2);
  else
    printf("%s is contained within %s is FALSE!\n", str1, str2);
  free(buffy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
movq   $0x0,-0x218(%rbp)
movl   $0x0,-0x21c(%rbp)
movl   $0x0,-0x220(%rbp)
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xdf0(%rip),%rdi
call   10a0 <scanf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1060 <rewind@plt>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xdc1(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x21c(%rbp)
lea    -0x210(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x220(%rbp)
mov    -0x21c(%rbp),%eax
add    -0x220(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    12b8 <main+0x108>
movl   $0x0,-0x4(%rbp)
jmp    13c1 <main+0x211>
mov    -0x218(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xd46(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0x218(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x218(%rbp),%rsi
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1338 <main+0x188>
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1354 <main+0x1a4>
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     1392 <main+0x1e2>
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ae <main+0x1fe>
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x218(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xd51(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd56(%rip),%r15
lea    0x100(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <scanf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
call   1080 <rewind@plt>
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     13ae <main+0x1fe>
mov    %rax,%rbx
lea    0x100(%rsp),%r14
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   10c0 <strcat@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
lea    0xcce(%rip),%rax
lea    0xcda(%rip),%rdi
cmove  %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
lea    0xcef(%rip),%rax
lea    0xcc4(%rip),%rdi
cmove  %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Type in a string: \00"
@.str.1 = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.2 = [25 x i8] c"Type in another string: \00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [19 x i8] c"%s is equal to %s\0A\00"
@.str.5 = [23 x i8] c"%s is not equal to %s\0A\00"
@.str.6 = [36 x i8] c"%s is contained within %s is TRUE!\0A\00"
@.str.7 = [37 x i8] c"%s is contained within %s is FALSE!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [256 x i8]* %2 to i8*
%8 = bitcast [256 x i8]* %3 to i8*
store i8* null, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stdin
%13 = call i32 @rewind(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %5
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = add nsw i32 %21, %22
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = mul i64 1, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %4
%30 = load i8*, i8** %4
%31 = icmp ne i8* %30, null
br i1 %31, label %33, label %32
32: ; preds = %0
store i32 0, i32* %1
br label %70
33: ; preds = %0
%34 = load i8*, i8** %4
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%36 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %4
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = load i8*, i8** %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%44 = call i64 @strcmp(i8* %42, i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %33
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %47, i8* %48)
br label %54
50: ; preds = %33
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %51, i8* %52)
br label %54
54: ; preds = %50, %46
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%57 = call i64 @strstr(i8* %55, i8* %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %54
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %60, i8* %61)
br label %67
63: ; preds = %54
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %64, i8* %65)
br label %67
67: ; preds = %63, %59
%68 = load i8*, i8** %4
%69 = call i32 @free(i8* %68)
store i32 0, i32* %1
br label %70
70: ; preds = %67, %32
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [19 x i8] c"Type in a string: \00"
@.str.1 = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.2 = [25 x i8] c"Type in another string: \00"
@.str.4 = [19 x i8] c"%s is equal to %s\0A\00"
@.str.5 = [23 x i8] c"%s is not equal to %s\0A\00"
@.str.6 = [36 x i8] c"%s is contained within %s is TRUE!\0A\00"
@.str.7 = [37 x i8] c"%s is contained within %s is FALSE!\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 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 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i32, i32* @stdin
%8 = call i32 @rewind(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i32 @strlen(i8* %3)
%12 = call i32 @strlen(i8* %4)
%13 = add i32 %11, 1
%14 = add i32 %13, %12
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = icmp eq i64 %15, 0
br i1 %17, label %31, label %18
18: ; preds = %0
%19 = call i8* @strcpy(i8* %16, i8* %3)
%20 = call i32 @strcat(i8* %16, i8* %4)
%21 = call i32 @puts(i8* %16)
%22 = call i64 @strcmp(i8* %3, i8* %4)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i8* %3, i8* %4)
%26 = call i64 @strstr(i8* %4, i8* %3)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i8* %3, i8* %4)
%30 = call i32 @free(i8* %16)
br label %31
31: ; preds = %0, %18
ret i32 0
}