#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 EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
char *line_reading(int);
int /*<<< orphan*/ printf(char *, ...);
int substr_appears(char *, char *);
int main() {
  printf("Enter string\n");
  char *line = line_reading(200);
  printf("Enter search sub-string\n");
  char *search = line_reading(10);
  int appears = substr_appears(line, search);
  printf("%d", appears);
  free(line);
  free(search);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xc8,%edi
call   1060 <line_reading@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1060 <line_reading@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <substr_appears@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xc8,%edi
call   1070 <line_reading@plt>
mov    %rax,%r14
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1070 <line_reading@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <substr_appears@plt>
lea    0xe68(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter string\0A\00"
@.str.1 = [25 x i8] c"Enter search sub-string\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @line_reading(i32 200)
store i8* %6, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%8 = call i8* @line_reading(i32 10)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = load i8*, i8** %3
%11 = call i32 @substr_appears(i8* %9, i8* %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
@str = [13 x i8] c"Enter string\00"
@str.3 = [24 x i8] c"Enter search sub-string\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* @line_reading(i32 200)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
%4 = tail call i8* @line_reading(i32 10)
%5 = tail call i32 @substr_appears(i8* %2, i8* %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @free(i8* %2)
%8 = tail call i32 @free(i8* %4)
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}