#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int length(char const *);
int /*<<< orphan*/ stderr;
int indexOfCharAfterIndex(const char *a, char e, int offset) {
  if (a == NULL) {
    fprintf(stderr, "NULL Pointer Exception at indexOfCharAfterIndex\n");
    exit(-1);
  }
  int len = length(a);
  if (offset < 0 || offset > len) {
    fprintf(stderr, "Index out of Bounds Exception at indexOfCharAfterIndex\n");
    exit(-1);
  }
  int i = offset;
  for (; i < len; i++) {
    if (a[i] == e) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<indexOfCharAfterIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116f <indexOfCharAfterIndex+0x3f>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1191 <indexOfCharAfterIndex+0x61>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11b0 <indexOfCharAfterIndex+0x80>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f8 <indexOfCharAfterIndex+0xc8>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11e5 <indexOfCharAfterIndex+0xb5>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ff <indexOfCharAfterIndex+0xcf>
jmp    11ea <indexOfCharAfterIndex+0xba>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b6 <indexOfCharAfterIndex+0x86>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indexOfCharAfterIndex>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1178 <indexOfCharAfterIndex+0x48>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <length@plt>
test   %r14d,%r14d
js     118a <indexOfCharAfterIndex+0x5a>
mov    %eax,%ecx
cmp    %r14d,%eax
jl     118a <indexOfCharAfterIndex+0x5a>
mov    $0xffffffff,%eax
jle    1173 <indexOfCharAfterIndex+0x43>
mov    %r14d,%edx
movslq %ecx,%rcx
nop
cmp    %bpl,(%rbx,%rdx,1)
je     1171 <indexOfCharAfterIndex+0x41>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1160 <indexOfCharAfterIndex+0x30>
jmp    1173 <indexOfCharAfterIndex+0x43>
mov    %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
jmp    119a <indexOfCharAfterIndex+0x6a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"NULL Pointer Exception at indexOfCharAfterIndex\0A\00"
@.str.1 = [56 x i8] c"Index out of Bounds Exception at indexOfCharAfterIndex\0A\00"
define i32 @indexOfCharAfterIndex(i8* %0, i8 signext %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = call i32 @length(i8* %17)
store i32 %18, i32* %8
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21, %16
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %21
%30 = load i32, i32* %7
store i32 %30, i32* %9
br label %31
31: ; preds = %48, %29
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %51
35: ; preds = %31
%36 = load i8*, i8** %5
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %47
45: ; preds = %35
%46 = load i32, i32* %9
store i32 %46, i32* %4
br label %52
47: ; preds = %35
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %31
51: ; preds = %31
store i32 -1, i32* %4
br label %52
52: ; preds = %51, %45
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"NULL Pointer Exception at indexOfCharAfterIndex\0A\00"
@.str.1 = [56 x i8] c"Index out of Bounds Exception at indexOfCharAfterIndex\0A\00"
define i32 @indexOfCharAfterIndex(i8* %0, i8 signext %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %3
%10 = tail call i32 @length(i8* %0)
%11 = icmp slt i32 %2, 0
%12 = icmp slt i32 %10, %2
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %19, label %14
14: ; preds = %9
%15 = icmp sgt i32 %10, %2
br i1 %15, label %16, label %33
16: ; preds = %14
%17 = zext i32 %2 to i64
%18 = sext i32 %10 to i64
br label %23
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %16, %28
%24 = phi i64 [ %17, %16 ], [ %29, %28 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, %1
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %18
br i1 %30, label %33, label %23
31: ; preds = %23
%32 = trunc i64 %24 to i32
br label %33
33: ; preds = %28, %31, %14
%34 = phi i32 [ -1, %14 ], [ %32, %31 ], [ -1, %28 ]
ret i32 %34
}