#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 Index_String_BF1(char *, char *);
int StrComp(char *, char *);
int /*<<< orphan*/ StrConcat(char *, char *);
int StrLength(char *);
int /*<<< orphan*/ SubStr(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char s1[255] = "helli", s2[255] = "hello";
  char s3[255];
  char s4[255] = "This is liliang, who are you?";
  SubStr(s3, s4, 6, 10);
  int len1 = StrLength(s1);
  int cmp = StrComp(s1, s2);
  StrConcat(s1, s2);
  printf("s1: %s\n", s1);
  printf("s2: %s\n", s2);
  int index = Index_String_BF1(s1, s2);
  if (index != StrLength(s4))
    printf("the index is: %d\n", index);
  else
    printf("the sub string is not found\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
movb   $0x68,-0x110(%rbp)
movb   $0x65,-0x10f(%rbp)
movb   $0x6c,-0x10e(%rbp)
movb   $0x6c,-0x10d(%rbp)
movb   $0x69,-0x10c(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
movb   $0x68,-0x210(%rbp)
movb   $0x65,-0x20f(%rbp)
movb   $0x6c,-0x20e(%rbp)
movb   $0x6c,-0x20d(%rbp)
movb   $0x6f,-0x20c(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xdf4(%rip),%rsi
mov    $0xff,%edx
call   1060 <memcpy@plt>
lea    -0x310(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x6,%edx
mov    $0xa,%ecx
call   1030 <SubStr@plt>
lea    -0x110(%rbp),%rdi
call   10a0 <StrLength@plt>
mov    %eax,-0x414(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1080 <StrComp@plt>
mov    %eax,-0x418(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1070 <StrConcat@plt>
lea    -0x110(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1090 <Index_String_BF1@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x41c(%rbp),%eax
mov    %eax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
call   10a0 <StrLength@plt>
mov    %eax,%ecx
mov    -0x420(%rbp),%eax
cmp    %ecx,%eax
je     12f5 <main+0x175>
mov    -0x41c(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1303 <main+0x183>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movups %xmm0,0x1ef(%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)
movl   $0x6c6c6568,0x100(%rsp)
68 65 6c 6c
movb   $0x69,0x104(%rsp)
69
movaps %xmm0,(%rsp)
movups %xmm0,0xef(%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)
movl   $0x6c6c6568,(%rsp)
movb   $0x6f,0x4(%rsp)
lea    0xd64(%rip),%rsi
lea    0x200(%rsp),%r14
mov    $0xff,%edx
mov    %r14,%rdi
call   1060 <memcpy@plt>
lea    0x300(%rsp),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
mov    $0xa,%ecx
call   1030 <SubStr@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <StrLength@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <StrComp@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <StrConcat@plt>
lea    0xe04(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdfb(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <Index_String_BF1@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   10a0 <StrLength@plt>
cmp    %eax,%ebx
jne    133d <main+0x1bd>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
jmp    134d <main+0x1cd>
lea    0xdcb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s4 = [255 x i8] c"This is liliang, who are you?\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"s1: %s\0A\00"
@.str.1 = [8 x i8] c"s2: %s\0A\00"
@.str.2 = [18 x i8] c"the index is: %d\0A\00"
@.str.3 = [29 x i8] c"the sub string is not found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [255 x i8]* %2 to i8*
%10 = bitcast i8* %9 to [255 x i8]*
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 0
store i8 104, i8* %11
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 1
store i8 101, i8* %12
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 2
store i8 108, i8* %13
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 3
store i8 108, i8* %14
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i32 0, i32 4
store i8 105, i8* %15
%16 = bitcast [255 x i8]* %3 to i8*
%17 = bitcast i8* %16 to [255 x i8]*
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i32 0, i32 0
store i8 104, i8* %18
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i32 0, i32 1
store i8 101, i8* %19
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i32 0, i32 2
store i8 108, i8* %20
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i32 0, i32 3
store i8 108, i8* %21
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %17, i32 0, i32 4
store i8 111, i8* %22
%23 = bitcast [255 x i8]* %5 to i8*
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%26 = call i32 @SubStr(i8* %24, i8* %25, i32 6, i32 10)
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%28 = call i32 @StrLength(i8* %27)
store i32 %28, i32* %6
%29 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%31 = call i32 @StrComp(i8* %29, i8* %30)
store i32 %31, i32* %7
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%34 = call i32 @StrConcat(i8* %32, i8* %33)
%35 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%41 = call i32 @Index_String_BF1(i8* %39, i8* %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%44 = call i32 @StrLength(i8* %43)
%45 = icmp ne i32 %42, %44
br i1 %45, label %46, label %49
46: ; preds = %0
%47 = load i32, i32* %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
ret i32 0
}

LLVM IR (-O2):
@__const.main.s4 = [255 x i8] c"This is liliang, who are you?\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"s1: %s\0A\00"
@.str.1 = [8 x i8] c"s2: %s\0A\00"
@.str.2 = [18 x i8] c"the index is: %d\0A\00"
@str = [28 x i8] c"the sub string is not found\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = alloca [255 x i8]
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
store i8 104, i8* %5
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 1
store i8 101, i8* %6
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 2
store i8 108, i8* %7
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 3
store i8 108, i8* %8
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 4
store i8 105, i8* %9
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
store i8 104, i8* %10
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 1
store i8 101, i8* %11
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 2
store i8 108, i8* %12
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 3
store i8 108, i8* %13
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 4
store i8 111, i8* %14
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%17 = call i32 @SubStr(i8* %15, i8* %16, i32 6, i32 10)
%18 = call i32 @StrLength(i8* %5)
%19 = call i32 @StrComp(i8* %5, i8* %10)
%20 = call i32 @StrConcat(i8* %5, i8* %10)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %5)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%23 = call i32 @Index_String_BF1(i8* %5, i8* %10)
%24 = call i32 @StrLength(i8* %16)
%25 = icmp eq i32 %23, %24
br i1 %25, label %28, label %26
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %30
28: ; preds = %0
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
ret i32 0
}