#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*/ abort();
int backtrace(void **, int);
scalar_t__ backtrace_symbols(void **, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *,
                           int, char *);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ simple_now_iso8601(char *);
scalar_t__ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int strlen(char const *);
int /*<<< orphan*/ va_list_print(char *, char *);
char simple_string_at(const char *self, int index) {
  if (!(index < strlen(self))) {
    char __log_time__[64] = {0};
    simple_now_iso8601(__log_time__);
    char __buffer_stack__[1024];
    void *__array__[10];
    char **__strframe__ = NULL;
    int __i__, __idx__ = 0, __n__ = backtrace(__array__, 10);
    __strframe__ = (char **)backtrace_symbols(__array__, __n__);
    for (__i__ = 0; __i__ < __n__; __i__++)
      __idx__ += snprintf(__idx__ + __buffer_stack__, 256, "%s\n",
                          __strframe__[__i__]);
    free(__strframe__);
    char __log_message__[512] = {0};
    va_list_print(__log_message__, "The index out of range.");
    fprintf(stderr, "%s, Assert fail ! %s\t[%s:%d]\n%s\n", (__log_time__),
            (__log_message__),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/red-chen/lemon/refs/heads/master/src/"
            "string_tool.c",
            13, __buffer_stack__);
    abort();
  };
  return self[index];
}


x86 assembly (clang, -O0):
<simple_string_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6d0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x6c4(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c4(%rbp),%eax
cmp    %ecx,%eax
jl     131b <simple_string_at+0x17b>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1090 <memset@plt>
lea    -0x50(%rbp),%rdi
call   10a0 <simple_now_iso8601@plt>
movq   $0x0,-0x4a8(%rbp)
movl   $0x0,-0x4b0(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    $0xa,%esi
call   1070 <backtrace@plt>
mov    %eax,-0x4b4(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x4b4(%rbp),%esi
call   1050 <backtrace_symbols@plt>
mov    %rax,-0x4a8(%rbp)
movl   $0x0,-0x4ac(%rbp)
mov    -0x4ac(%rbp),%eax
cmp    -0x4b4(%rbp),%eax
jge    12aa <simple_string_at+0x10a>
mov    -0x4b0(%rbp),%eax
lea    -0x450(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x4a8(%rbp),%rax
movslq -0x4ac(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0x100,%esi
lea    0xdb7(%rip),%rdx
call   1080 <snprintf@plt>
mov    %rax,%rcx
movslq -0x4b0(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4b0(%rbp)
mov    -0x4ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4ac(%rbp)
jmp    123c <simple_string_at+0x9c>
mov    -0x4a8(%rbp),%rdi
call   1030 <free@plt>
lea    -0x6c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1090 <memset@plt>
lea    -0x6c0(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   10c0 <va_list_print@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
lea    -0x6c0(%rbp),%rcx
lea    -0x450(%rbp),%rax
lea    0xd1a(%rip),%rsi
lea    0xd34(%rip),%r8
mov    $0xd,%r9d
mov    %rax,(%rsp)
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x6d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_string_at>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x6a0,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
call   1060 <strlen@plt>
cmp    %ebp,%eax
jle    11d3 <simple_string_at+0x33>
movslq %ebp,%rax
mov    (%rbx,%rax,1),%al
add    $0x6a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   10a0 <simple_now_iso8601@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <backtrace@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <backtrace_symbols@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    125b <simple_string_at+0xbb>
mov    %ebp,%r12d
xor    %ebx,%ebx
lea    0xe10(%rip),%r14
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x2a0,%rdi
mov    (%r15,%rbx,8),%rcx
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <snprintf@plt>
add    %rbp,%rax
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1230 <simple_string_at+0x90>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xa0(%rsp),%rbx
mov    $0x200,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
lea    0xd7f(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <va_list_print@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0x2a0(%rsp),%rax
mov    %rax,(%rsp)
lea    0xd73(%rip),%rsi
lea    0xd8d(%rip),%r8
lea    0x10(%rsp),%rdx
mov    %rbx,%rcx
mov    $0xd,%r9d
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [24 x i8] c"The index out of range.\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"%s, Assert fail ! %s\09[%s:%d]\0A%s\0A\00"
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/red-chen/lemon/refs/heads/master/src/string_tool.c\00"
define signext i8 @simple_string_at(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [10 x i8*]
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [512 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%13 = load i32, i32* %4
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %13, %15
br i1 %16, label %61, label %17
17: ; preds = %2
%18 = bitcast [64 x i8]* %5 to i8*
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%20 = call i32 @simple_now_iso8601(i8* %19)
store i8** null, i8*** %8
store i32 0, i32* %10
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%22 = call i32 @backtrace(i8** %21, i32 10)
store i32 %22, i32* %11
%23 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%24 = load i32, i32* %11
%25 = call i64 @backtrace_symbols(i8** %23, i32 %24)
%26 = inttoptr i64 %25 to i8**
store i8** %26, i8*** %8
store i32 0, i32* %9
br label %27
27: ; preds = %46, %17
%28 = load i32, i32* %9
%29 = load i32, i32* %11
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load i32, i32* %10
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %33, i64 %34
%36 = load i8**, i8*** %8
%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 = call i64 @snprintf(i8* %35, i32 256, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = add nsw i64 %43, %41
%45 = trunc i64 %44 to i32
store i32 %45, i32* %10
br label %46
46: ; preds = %31
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %27
49: ; preds = %27
%50 = load i8**, i8*** %8
%51 = call i32 @free(i8** %50)
%52 = bitcast [512 x i8]* %12 to i8*
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%54 = call i32 @va_list_print(i8* %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%59 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %56, i8* %57, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 13, i8* %58)
%60 = call i32 (...) @abort()
unreachable
61: ; preds = %2
%62 = load i8*, i8** %3
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
ret i8 %66
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [24 x i8] c"The index out of range.\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"%s, Assert fail ! %s\09[%s:%d]\0A%s\0A\00"
@.str.3 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/red-chen/lemon/refs/heads/master/src/string_tool.c\00"
define signext i8 @simple_string_at(i8* %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [10 x i8*]
%6 = alloca [512 x i8]
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, %1
br i1 %8, label %40, label %9
9: ; preds = %2
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @simple_now_iso8601(i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = bitcast [10 x i8*]* %5 to i8*
%14 = getelementptr inbounds [10 x i8*], [10 x i8*]* %5, i64 0, i64 0
%15 = call i32 @backtrace(i8** %14, i32 10)
%16 = call i64 @backtrace_symbols(i8** %14, i32 %15)
%17 = inttoptr i64 %16 to i8**
%18 = icmp sgt i32 %15, 0
br i1 %18, label %19, label %33
19: ; preds = %9
%20 = zext i32 %15 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %31, %21 ]
%23 = phi i64 [ 0, %19 ], [ %30, %21 ]
%24 = shl i64 %23, 32
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %25
%27 = getelementptr inbounds i8*, i8** %17, i64 %22
%28 = load i8*, i8** %27
%29 = call i64 @snprintf(i8* %26, i32 256, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = add nsw i64 %29, %25
%31 = add nuw nsw i64 %22, 1
%32 = icmp eq i64 %31, %20
br i1 %32, label %33, label %21
33: ; preds = %21, %9
%34 = call i32 @free(i8** %17)
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%36 = call i32 @va_list_print(i8* %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %35, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.3, i64 0, i64 0), i32 13, i8* %12)
%39 = call i32 (...) @abort()
unreachable
40: ; preds = %2
%41 = sext i32 %1 to i64
%42 = getelementptr inbounds i8, i8* %0, i64 %41
%43 = load i8, i8* %42
ret i8 %43
}