#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*/ printf(char *);
int /*<<< orphan*/ test_extract(char *, char *, char *);
int main(void) {
  printf("\nWorking\n");
  test_extract("asdf2dlkj<<$@3f>>", "<<", ">>");
  printf("\nWorking\n");
  test_extract("asdf<<value == \"hi!\">>qqqq", "<<value == \"", "\">>");
  printf("\nEmpty Start\n");
  test_extract("asdf<<value == \"hi!\">>qqqq", NULL, "\">>");
  printf("\nEmpty End\n");
  test_extract("asdf<<value == \"hi!\">>qqqq", "<<value == \"", NULL);
  printf("\nEmpty Source\n");
  test_extract(NULL, "<<value == \"", "\">>");
  printf("\nStrings Identical\n");
  test_extract("<<hi>>", "<<hi>>", "<<hi>>");
  printf("\nStart not in Source\n");
  test_extract("<<hi>>", "asdf", ">>");
  printf("\nEnd not in Source\n");
  test_extract("<<hi>>", "<<", "asdf");
  printf("\nNeither in Source\n");
  test_extract("<<hi>>", "j", "f");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0xede(%rip),%rsi
lea    0xf03(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xed6(%rip),%rsi
lea    0xedc(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xed4(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    0xeb9(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <test_extract@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6d(%rip),%rsi
lea    0xe73(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdx
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1030 <test_extract@plt>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    0xe94(%rip),%rsi
lea    0xe30(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
lea    0xde5(%rip),%rsi
lea    0xe67(%rip),%rdx
call   1030 <test_extract@plt>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    0xe75(%rip),%rsi
lea    0xe44(%rip),%rdx
call   1030 <test_extract@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xf1f(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xec1(%rip),%rdi
lea    0xecc(%rip),%r14
lea    0xef1(%rip),%r15
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <test_extract@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xeae(%rip),%rbx
lea    0xec2(%rip),%r13
lea    0xec8(%rip),%r12
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <test_extract@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12,%rdx
call   1030 <test_extract@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %edx,%edx
call   1030 <test_extract@plt>
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <test_extract@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe60(%rip),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1030 <test_extract@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe46(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <test_extract@plt>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <test_extract@plt>
lea    0xe88(%rip),%rdi
call   1040 <puts@plt>
lea    0xe10(%rip),%rsi
lea    0xe07(%rip),%rdx
mov    %rbx,%rdi
call   1030 <test_extract@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\0AWorking\0A\00"
@.str.1 = [18 x i8] c"asdf2dlkj<<$@3f>>\00"
@.str.2 = [3 x i8] c"<<\00"
@.str.3 = [3 x i8] c">>\00"
@.str.4 = [27 x i8] c"asdf<<value == \22hi!\22>>qqqq\00"
@.str.5 = [13 x i8] c"<<value == \22\00"
@.str.6 = [4 x i8] c"\22>>\00"
@.str.7 = [14 x i8] c"\0AEmpty Start\0A\00"
@.str.8 = [12 x i8] c"\0AEmpty End\0A\00"
@.str.9 = [15 x i8] c"\0AEmpty Source\0A\00"
@.str.10 = [20 x i8] c"\0AStrings Identical\0A\00"
@.str.11 = [7 x i8] c"<<hi>>\00"
@.str.12 = [22 x i8] c"\0AStart not in Source\0A\00"
@.str.13 = [5 x i8] c"asdf\00"
@.str.14 = [20 x i8] c"\0AEnd not in Source\0A\00"
@.str.15 = [20 x i8] c"\0ANeither in Source\0A\00"
@.str.16 = [2 x i8] c"j\00"
@.str.17 = [2 x i8] c"f\00"
define i32 @main() {
%1 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @test_extract(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%6 = call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%8 = call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* null)
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%10 = call i32 @test_extract(i8* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%12 = call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
%14 = call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%16 = call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
%18 = call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"asdf2dlkj<<$@3f>>\00"
@.str.2 = [3 x i8] c"<<\00"
@.str.3 = [3 x i8] c">>\00"
@.str.4 = [27 x i8] c"asdf<<value == \22hi!\22>>qqqq\00"
@.str.5 = [13 x i8] c"<<value == \22\00"
@.str.6 = [4 x i8] c"\22>>\00"
@.str.11 = [7 x i8] c"<<hi>>\00"
@.str.13 = [5 x i8] c"asdf\00"
@.str.16 = [2 x i8] c"j\00"
@.str.17 = [2 x i8] c"f\00"
@str.18 = [9 x i8] c"\0AWorking\00"
@str.19 = [13 x i8] c"\0AEmpty Start\00"
@str.20 = [11 x i8] c"\0AEmpty End\00"
@str.21 = [14 x i8] c"\0AEmpty Source\00"
@str.22 = [19 x i8] c"\0AStrings Identical\00"
@str.23 = [21 x i8] c"\0AStart not in Source\00"
@str.24 = [19 x i8] c"\0AEnd not in Source\00"
@str.25 = [19 x i8] c"\0ANeither in Source\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0))
%2 = tail call i32 @test_extract(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0))
%4 = tail call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.19, i64 0, i64 0))
%6 = tail call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.20, i64 0, i64 0))
%8 = tail call i32 @test_extract(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* null)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.21, i64 0, i64 0))
%10 = tail call i32 @test_extract(i8* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.22, i64 0, i64 0))
%12 = tail call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0))
%14 = tail call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.24, i64 0, i64 0))
%16 = tail call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.25, i64 0, i64 0))
%18 = tail call i32 @test_extract(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}