#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 */
scalar_t__ SCNormalloc(int, char *, int);
int sc_strlen(char *);
char *sc_substr(char *A, int start, int end) {
  int walker = start;
  int counter = 0;
  char *results =
      (char *)SCNormalloc(end,
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                          "astrotycoon/semo/refs/heads/master/common/sccl.c",
                          326);
  if (!results)
    return 0;
  for (; walker < sc_strlen(A) && walker < start + end; walker++, counter++)
    results[counter] = A[walker];
  results[counter] = 0;
  return results;
}


x86 assembly (clang, -O0):
<sc_substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    0xeb7(%rip),%rsi
mov    $0x146,%edx
call   1040 <SCNormalloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116f <sc_substr+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    11f7 <sc_substr+0xd7>
jmp    1174 <sc_substr+0x54>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    -0x30(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x29(%rbp)
jge    11a6 <sc_substr+0x86>
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
cmp    %ecx,%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11b6 <sc_substr+0x96>
jmp    11e3 <sc_substr+0xc3>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1174 <sc_substr+0x54>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_substr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r13
lea    0xec5(%rip),%rsi
mov    %edx,%edi
mov    $0x146,%edx
call   1040 <SCNormalloc@plt>
test   %rax,%rax
je     11b0 <sc_substr+0x90>
mov    %rax,%r14
mov    %r13,%rdi
call   1030 <sc_strlen@plt>
xor    %ebp,%ebp
cmp    %r15d,%eax
jle    11a9 <sc_substr+0x89>
test   %r12d,%r12d
jle    11a9 <sc_substr+0x89>
add    %r15d,%r12d
movslq %r15d,%rbx
movslq %r12d,%r15
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x1(%r13,%rbx,1),%eax
mov    %al,(%r14,%rbp,1)
add    $0x1,%rbp
mov    %r13,%rdi
call   1030 <sc_strlen@plt>
cltq
cmp    %rax,%rbx
jge    11a9 <sc_substr+0x89>
lea    0x1(%rbx),%rax
cmp    %r15,%rbx
mov    %rax,%rbx
jl     1180 <sc_substr+0x60>
movb   $0x0,(%r14,%rbp,1)
jmp    11b3 <sc_substr+0x93>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/astrotycoon/semo/refs/heads/master/common/sccl.c\00"
define i8* @sc_substr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %6
store i32 %11, i32* %8
store i32 0, i32* %9
%12 = load i32, i32* %7
%13 = call i64 @SCNormalloc(i32 %12, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 326)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %10
%15 = load i8*, i8** %10
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
store i8* null, i8** %4
br label %53
18: ; preds = %3
br label %19
19: ; preds = %42, %18
%20 = load i32, i32* %8
%21 = load i8*, i8** %5
%22 = call i32 @sc_strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = add nsw i32 %26, %27
%29 = icmp slt i32 %25, %28
br label %30
30: ; preds = %24, %19
%31 = phi i1 [ false, %19 ], [ %29, %24 ]
br i1 %31, label %32, label %47
32: ; preds = %30
%33 = load i8*, i8** %5
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %10
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %32
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %19
47: ; preds = %30
%48 = load i8*, i8** %10
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
%52 = load i8*, i8** %10
store i8* %52, i8** %4
br label %53
53: ; preds = %47, %17
%54 = load i8*, i8** %4
ret i8* %54
}

LLVM IR (-O2):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/astrotycoon/semo/refs/heads/master/common/sccl.c\00"
define i8* @sc_substr(i8* %0, i32 %1, i32 %2) {
%4 = tail call i64 @SCNormalloc(i32 %2, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 326)
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i64 %4, 0
br i1 %6, label %34, label %7
7: ; preds = %3
%8 = tail call i32 @sc_strlen(i8* %0)
%9 = icmp sgt i32 %8, %1
%10 = icmp sgt i32 %2, 0
%11 = and i1 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %7
%13 = add nsw i32 %2, %1
%14 = sext i32 %1 to i64
%15 = sext i32 %13 to i64
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ %14, %12 ], [ %22, %16 ]
%18 = phi i64 [ 0, %12 ], [ %23, %16 ]
%19 = getelementptr inbounds i8, i8* %0, i64 %17
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %5, i64 %18
store i8 %20, i8* %21
%22 = add nsw i64 %17, 1
%23 = add nuw nsw i64 %18, 1
%24 = tail call i32 @sc_strlen(i8* %0)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %22, %25
%27 = icmp slt i64 %22, %15
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %16, label %29
29: ; preds = %16
%30 = and i64 %23, 4294967295
br label %31
31: ; preds = %29, %7
%32 = phi i64 [ 0, %7 ], [ %30, %29 ]
%33 = getelementptr inbounds i8, i8* %5, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %3, %31
%35 = phi i8* [ %5, %31 ], [ null, %3 ]
ret i8* %35
}