#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_with_atom(char *A, char atom) {
  int len = sc_strlen(A);
  int walker = 0;
  char *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",
                          303);
  if (!B)
    return 0;
  for (walker = 0; '\0' != A[walker] && atom != A[walker]; walker++) {
    B[walker] = A[walker];
  }
  B[walker] = '\0';
  return B;
}


x86 assembly (clang, -O0):
<sc_substr_with_atom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
lea    0xeb1(%rip),%rsi
mov    $0x12f,%edx
call   1040 <SCNormalloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1175 <sc_substr_with_atom+0x55>
movq   $0x0,-0x8(%rbp)
jmp    11f7 <sc_substr_with_atom+0xd7>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x29(%rbp)
je     11af <sc_substr_with_atom+0x8f>
movsbl -0x11(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11bf <sc_substr_with_atom+0x9f>
jmp    11e3 <sc_substr_with_atom+0xc3>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <sc_substr_with_atom+0x5c>
mov    -0x28(%rbp),%rax
movslq -0x1c(%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_with_atom>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <sc_strlen@plt>
lea    0xecc(%rip),%rsi
mov    %eax,%edi
mov    $0x12f,%edx
call   1040 <SCNormalloc@plt>
test   %rax,%rax
je     117d <sc_substr_with_atom+0x5d>
mov    (%rbx),%cl
xor    %edx,%edx
test   %cl,%cl
je     1177 <sc_substr_with_atom+0x57>
cmp    %bpl,%cl
je     1177 <sc_substr_with_atom+0x57>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %cl,(%rax,%rdx,1)
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
je     1175 <sc_substr_with_atom+0x55>
cmp    %bpl,%cl
jne    1160 <sc_substr_with_atom+0x40>
mov    %edx,%edx
movb   $0x0,(%rax,%rdx,1)
jmp    117f <sc_substr_with_atom+0x5f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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_atom(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
%9 = load i8*, i8** %4
%10 = call i32 @sc_strlen(i8* %9)
store i32 %10, i32* %6
store i32 0, i32* %7
%11 = load i32, i32* %6
%12 = call i64 @SCNormalloc(i32 %11, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 303)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %2
store i8* null, i8** %3
br label %57
17: ; preds = %2
store i32 0, i32* %7
br label %18
18: ; preds = %48, %17
%19 = load i8*, i8** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 0, %24
br i1 %25, label %26, label %36
26: ; preds = %18
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %4
%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 = sext i8 %33 to i32
%35 = icmp ne i32 %28, %34
br label %36
36: ; preds = %26, %18
%37 = phi i1 [ false, %18 ], [ %35, %26 ]
br i1 %37, label %38, label %51
38: ; preds = %36
%39 = load i8*, i8** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = load i8*, i8** %8
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %38
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %18
51: ; preds = %36
%52 = load i8*, i8** %8
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
%56 = load i8*, i8** %8
store i8* %56, i8** %3
br label %57
57: ; preds = %51, %16
%58 = load i8*, i8** %3
ret i8* %58
}

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_atom(i8* %0, i8 signext %1) {
%3 = tail call i32 @sc_strlen(i8* %0)
%4 = tail call i64 @SCNormalloc(i32 %3, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 303)
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i64 %4, 0
br i1 %6, label %27, label %7
7: ; preds = %2
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
%10 = icmp eq i8 %8, %1
%11 = or i1 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %16, %12 ], [ 0, %7 ]
%14 = phi i8 [ %18, %12 ], [ %8, %7 ]
%15 = getelementptr inbounds i8, i8* %5, i64 %13
store i8 %14, i8* %15
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
%20 = icmp eq i8 %18, %1
%21 = or i1 %19, %20
br i1 %21, label %22, label %12
22: ; preds = %12
%23 = and i64 %16, 4294967295
br label %24
24: ; preds = %22, %7
%25 = phi i64 [ 0, %7 ], [ %23, %22 ]
%26 = getelementptr inbounds i8, i8* %5, i64 %25
store i8 0, i8* %26
br label %27
27: ; preds = %2, %24
%28 = phi i8* [ %5, %24 ], [ null, %2 ]
ret i8* %28
}