#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);
scalar_t__ sc_is_alpha(char);
scalar_t__ sc_is_digit(char);
int sc_strlen(char *);
char *sc_substr_with_pos(char *A, char *B, int pos) {
  int len = sc_strlen(A);
  int walker = 0;
  if (pos >= len)
    return 0;
  B = (char *)SCNormalloc(len,
                          "/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",
                          277);
  if (!B)
    return 0;
  for (walker = 0; pos < len && (sc_is_alpha(A[pos]) || sc_is_digit(A[pos]) ||
                                 '_' == A[pos]);
       pos++, walker++) {
    B[walker] = A[pos];
  }
  B[walker] = '\0';
  return B;
}


x86 assembly (clang, -O0):
<sc_substr_with_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     117f <sc_substr_with_pos+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    127d <sc_substr_with_pos+0x13d>
mov    -0x20(%rbp),%edi
lea    0xe77(%rip),%rsi
mov    $0x115,%edx
call   1050 <SCNormalloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <sc_substr_with_pos+0x6f>
movq   $0x0,-0x8(%rbp)
jmp    127d <sc_substr_with_pos+0x13d>
movl   $0x0,-0x24(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x20(%rbp),%ecx
mov    %al,-0x25(%rbp)
jge    122c <sc_substr_with_pos+0xec>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <sc_is_alpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x26(%rbp)
jne    1226 <sc_substr_with_pos+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <sc_is_digit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x26(%rbp)
jne    1226 <sc_substr_with_pos+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x5f,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    123c <sc_substr_with_pos+0xfc>
jmp    1269 <sc_substr_with_pos+0x129>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b6 <sc_substr_with_pos+0x76>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_substr_with_pos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rdi,%rbx
call   1030 <sc_strlen@plt>
mov    %eax,%r12d
sub    %r15d,%r12d
jle    11c0 <sc_substr_with_pos+0x80>
lea    0xe9e(%rip),%rsi
mov    %eax,%edi
mov    $0x115,%edx
call   1050 <SCNormalloc@plt>
test   %rax,%rax
je     11c0 <sc_substr_with_pos+0x80>
mov    %rax,%r14
movslq %r15d,%rax
add    %rax,%rbx
xor    %ebp,%ebp
jmp    1191 <sc_substr_with_pos+0x51>
movzbl (%rbx,%rbp,1),%eax
mov    %al,(%r14,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     11b6 <sc_substr_with_pos+0x76>
movsbl (%rbx,%rbp,1),%edi
call   1060 <sc_is_alpha@plt>
test   %rax,%rax
jne    1180 <sc_substr_with_pos+0x40>
movsbl (%rbx,%rbp,1),%edi
call   1040 <sc_is_digit@plt>
test   %rax,%rax
jne    1180 <sc_substr_with_pos+0x40>
cmpb   $0x5f,(%rbx,%rbp,1)
je     1180 <sc_substr_with_pos+0x40>
mov    %ebp,%r12d
mov    %r12d,%eax
movb   $0x0,(%r14,%rax,1)
jmp    11c3 <sc_substr_with_pos+0x83>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r12
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_with_pos(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%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 = call i32 @sc_strlen(i8* %10)
store i32 %11, i32* %8
store i32 0, i32* %9
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %3
store i8* null, i8** %4
br label %77
16: ; preds = %3
%17 = load i32, i32* %8
%18 = call i64 @SCNormalloc(i32 %17, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 277)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %16
store i8* null, i8** %4
br label %77
23: ; preds = %16
store i32 0, i32* %9
br label %24
24: ; preds = %66, %23
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %54
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = call i64 @sc_is_alpha(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %52, label %36
36: ; preds = %28
%37 = load i8*, i8** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = call i64 @sc_is_digit(i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %52, label %44
44: ; preds = %36
%45 = load i8*, i8** %5
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 95, %50
br label %52
52: ; preds = %44, %36, %28
%53 = phi i1 [ true, %36 ], [ true, %28 ], [ %51, %44 ]
br label %54
54: ; preds = %52, %24
%55 = phi i1 [ false, %24 ], [ %53, %52 ]
br i1 %55, label %56, label %71
56: ; preds = %54
%57 = load i8*, i8** %5
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = load i8*, i8** %6
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 %61, i8* %65
br label %66
66: ; preds = %56
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %24
71: ; preds = %54
%72 = load i8*, i8** %6
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 0, i8* %75
%76 = load i8*, i8** %6
store i8* %76, i8** %4
br label %77
77: ; preds = %71, %22, %15
%78 = load i8*, i8** %4
ret i8* %78
}

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_with_pos(i8* %0, i8* nocapture readnone %1, i32 %2) {
%4 = tail call i32 @sc_strlen(i8* %0)
%5 = icmp sgt i32 %4, %2
br i1 %5, label %6, label %40
6: ; preds = %3
%7 = tail call i64 @SCNormalloc(i32 %4, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 277)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %40, label %10
10: ; preds = %6
%11 = sext i32 %2 to i64
%12 = sub i32 %4, %2
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %10, %28
%15 = phi i64 [ %11, %10 ], [ %31, %28 ]
%16 = phi i64 [ 0, %10 ], [ %32, %28 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
%19 = tail call i64 @sc_is_alpha(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i8, i8* %17
%23 = tail call i64 @sc_is_digit(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8, i8* %17
%27 = icmp eq i8 %26, 95
br i1 %27, label %28, label %34
28: ; preds = %14, %21, %25
%29 = load i8, i8* %17
%30 = getelementptr inbounds i8, i8* %8, i64 %16
store i8 %29, i8* %30
%31 = add nsw i64 %15, 1
%32 = add nuw nsw i64 %16, 1
%33 = icmp eq i64 %32, %13
br i1 %33, label %36, label %14
34: ; preds = %25
%35 = trunc i64 %16 to i32
br label %36
36: ; preds = %28, %34
%37 = phi i32 [ %35, %34 ], [ %12, %28 ]
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %8, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %6, %3, %36
%41 = phi i8* [ %8, %36 ], [ null, %3 ], [ null, %6 ]
ret i8* %41
}