#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(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
char *strcasestr(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
char *strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strrchr(char *, char);
char *strstr(char *, char *);
int main(int argc, const char *argv[]) {
  char s[] = "hello";
  char *p = strchr(s, 'l');
  printf("%s\n", p);
  char *q = strchr(p + 1, 'l');
  printf("%s\n", q);
  char *a = strrchr(s, 'l');
  printf("%s\n", a);
  char *r = (char *)malloc(strlen(p) + 1);
  char *t = strcpy(r, p);
  printf("%s\n", t);
  free(r);
  char c = *p;
  *p = '\0';
  char *u = (char *)malloc(strlen(s) + 1);
  char *v = strcpy(u, s);
  printf("%s\n", v);
  printf("%s\n", s);
  free(u);
  *p = c;
  printf("%s\n", s);
  char x[] = "E";
  char y[] = "e";
  char *z1 = strstr(s, x);
  char *z2 = strstr(s, y);
  char *z3 = strcasestr(s, x);
  printf("%s\n", z1);
  printf("%s\n", z2);
  printf("%s\n", z3);
  char ab[10] = "good";
  char *cd = "bye";
  strcat(ab, cd);
  printf("%s\n", ab);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe41(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe3b(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1070 <printf@plt>
lea    -0x16(%rbp),%rdi
mov    $0x6c,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xd9a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x41(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x16(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    0xd47(%rip),%rdi
call   1070 <printf@plt>
lea    -0x16(%rbp),%rsi
lea    0xd37(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x41(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
lea    -0x16(%rbp),%rsi
lea    0xd15(%rip),%rdi
call   1070 <printf@plt>
mov    0xd0d(%rip),%ax
mov    %ax,-0x5a(%rbp)
mov    0xd06(%rip),%ax
mov    %ax,-0x5c(%rbp)
lea    -0x16(%rbp),%rdi
lea    -0x5a(%rbp),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x68(%rbp)
lea    -0x16(%rbp),%rdi
lea    -0x5c(%rbp),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x70(%rbp)
lea    -0x16(%rbp),%rdi
lea    -0x5a(%rbp),%rsi
call   10a0 <strcasestr@plt>
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xcbc(%rip),%rdi
call   1070 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xcac(%rip),%rdi
call   1070 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xc9c(%rip),%rdi
call   1070 <printf@plt>
mov    0xc9a(%rip),%rax
mov    %rax,-0x82(%rbp)
mov    0xc94(%rip),%ax
mov    %ax,-0x7a(%rbp)
lea    0xc7d(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0x82(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   10b0 <strcat@plt>
lea    -0x82(%rbp),%rsi
lea    0xc4f(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movw   $0x6f,0x14(%rsp)
movl   $0x6c6c6568,0x10(%rsp)
6c
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
mov    %rax,%r12
lea    0xe2d(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
lea    0x1(%r12),%rdi
mov    $0x6c,%esi
call   1060 <strchr@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    $0x6c,%esi
call   1080 <strrchr@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r12),%bpl
movb   $0x0,(%r12)
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %bpl,(%r12)
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <printf@plt>
movw   $0x45,0xe(%rsp)
lea    0xe(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   10c0 <strstr@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    $0x65,%esi
call   1060 <strchr@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %r12,%rsi
call   10a0 <strcasestr@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
movw   $0x0,0x20(%rsp)
movq   $0x646f6f67,0x18(%rsp)
6f 64
lea    0xcfd(%rip),%rsi
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s = [6 x i8] c"hello\00"
@.str = [4 x i8] c"%s\0A\00"
@__const.main.x = [2 x i8] c"E\00"
@__const.main.y = [2 x i8] c"e\00"
@__const.main.ab = [10 x i8] c"good\00\00\00\00\00\00"
@.str.1 = [4 x i8] c"bye\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [2 x i8]
%16 = alloca [2 x i8]
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca [10 x i8]
%21 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = bitcast [6 x i8]* %6 to i8*
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%24 = call i8* @strchr(i8* %23, i8 signext 108)
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i8* @strchr(i8* %28, i8 signext 108)
store i8* %29, i8** %8
%30 = load i8*, i8** %8
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%33 = call i8* @strrchr(i8* %32, i8 signext 108)
store i8* %33, i8** %9
%34 = load i8*, i8** %9
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %7
%37 = call i64 @strlen(i8* %36)
%38 = add nsw i64 %37, 1
%39 = call i64 @malloc(i64 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %10
%41 = load i8*, i8** %10
%42 = load i8*, i8** %7
%43 = call i8* @strcpy(i8* %41, i8* %42)
store i8* %43, i8** %11
%44 = load i8*, i8** %11
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %10
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %7
%49 = load i8, i8* %48
store i8 %49, i8* %12
%50 = load i8*, i8** %7
store i8 0, i8* %50
%51 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%52 = call i64 @strlen(i8* %51)
%53 = add nsw i64 %52, 1
%54 = call i64 @malloc(i64 %53)
%55 = inttoptr i64 %54 to i8*
store i8* %55, i8** %13
%56 = load i8*, i8** %13
%57 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%58 = call i8* @strcpy(i8* %56, i8* %57)
store i8* %58, i8** %14
%59 = load i8*, i8** %14
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %59)
%61 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %13
%64 = call i32 @free(i8* %63)
%65 = load i8, i8* %12
%66 = load i8*, i8** %7
store i8 %65, i8* %66
%67 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%68 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %67)
%69 = bitcast [2 x i8]* %15 to i8*
%70 = bitcast [2 x i8]* %16 to i8*
%71 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%72 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%73 = call i8* @strstr(i8* %71, i8* %72)
store i8* %73, i8** %17
%74 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%75 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%76 = call i8* @strstr(i8* %74, i8* %75)
store i8* %76, i8** %18
%77 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%78 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%79 = call i8* @strcasestr(i8* %77, i8* %78)
store i8* %79, i8** %19
%80 = load i8*, i8** %17
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %80)
%82 = load i8*, i8** %18
%83 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %82)
%84 = load i8*, i8** %19
%85 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %84)
%86 = bitcast [10 x i8]* %20 to i8*
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %21
%87 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%88 = load i8*, i8** %21
%89 = call i32 @strcat(i8* %87, i8* %88)
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%91 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %90)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [6 x i8] c"hello\00"
@.str = [4 x i8] c"%s\0A\00"
@__const.main.ab = [10 x i8] c"good\00\00\00\00\00\00"
@.str.1 = [4 x i8] c"bye\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = alloca i16
%5 = alloca [10 x i8]
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = call i8* @strchr(i8* %6, i8 signext 108)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = call i8* @strchr(i8* %9, i8 signext 108)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i8* @strrchr(i8* %6, i8 signext 108)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i64 @strlen(i8* dereferenceable(1) %7)
%15 = add nsw i64 %14, 1
%16 = call i64 @malloc(i64 %15)
%17 = inttoptr i64 %16 to i8*
%18 = call i8* @strcpy(i8* dereferenceable(1) %17, i8* dereferenceable(1) %7)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%20 = call i32 @free(i8* %17)
%21 = load i8, i8* %7
store i8 0, i8* %7
%22 = call i64 @strlen(i8* %6)
%23 = add nsw i64 %22, 1
%24 = call i64 @malloc(i64 %23)
%25 = inttoptr i64 %24 to i8*
%26 = call i8* @strcpy(i8* dereferenceable(1) %25, i8* %6)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%29 = call i32 @free(i8* %25)
store i8 %21, i8* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%31 = bitcast i16* %4 to i8*
store i16 69, i16* %4
%32 = call i8* @strstr(i8* %6, i8* %31)
%33 = call i8* bitcast (i8* (i8*, i8)* @strchr to i8* (i8*, i32)*)(i8* %6, i32 101)
%34 = call i8* @strcasestr(i8* %6, i8* %31)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %34)
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
ret i32 0
}