#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*/ assert_failed(char *, int);
int /*<<< orphan*/ char_inc_exc(char, unsigned int const, unsigned int const);
int string_mod(char *str, const unsigned int inclusive,
               const unsigned int exclusive, const char replace) {
  const char *in = str;
  int ret = 1;
  do {
    if (!(str))
      assert_failed("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Bytewerk/uClinux-ipcam/"
                    "refs/heads/master/buffer.c",
                    779);
  } while (0);
  while (1) {
    char c = *in++;
    if (c) {
      if (!char_inc_exc(c, inclusive, exclusive)) {
        c = replace;
        ret = 0;
      }
      if (c)
        *str++ = c;
    } else {
      *str = '\0';
      break;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<string_mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1162 <string_mod+0x42>
lea    0xea8(%rip),%rdi
mov    $0x30b,%esi
call   1040 <assert_failed@plt>
jmp    1167 <string_mod+0x47>
jmp    116c <string_mod+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x25(%rbp)
cmpb   $0x0,-0x25(%rbp)
je     11d4 <string_mod+0xb4>
mov    -0x25(%rbp),%al
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsbl %al,%edi
call   1030 <char_inc_exc@plt>
cmp    $0x0,%eax
jne    11b1 <string_mod+0x91>
mov    -0x11(%rbp),%al
mov    %al,-0x25(%rbp)
movl   $0x0,-0x24(%rbp)
cmpb   $0x0,-0x25(%rbp)
je     11cf <string_mod+0xaf>
mov    -0x25(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    11e0 <string_mod+0xc0>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e5 <string_mod+0xc5>
jmp    116c <string_mod+0x4c>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_mod>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,0x4(%rsp)
mov    %esi,%r15d
mov    %rdi,%r13
test   %rdi,%rdi
jne    114d <string_mod+0x2d>
lea    0xebd(%rip),%rdi
mov    $0x30b,%esi
call   1040 <assert_failed@plt>
mov    0x0(%r13),%al
test   %al,%al
je     11a8 <string_mod+0x88>
lea    0x1(%r13),%r12
mov    $0x1,%ebp
movzbl %bl,%r14d
jmp    117d <string_mod+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12),%eax
add    $0x1,%r12
test   %al,%al
je     11ad <string_mod+0x8d>
movsbl %al,%ebx
mov    %ebx,%edi
mov    %r15d,%esi
mov    0x4(%rsp),%edx
call   1030 <char_inc_exc@plt>
test   %eax,%eax
cmove  %eax,%ebp
movzbl %bl,%eax
cmove  %r14d,%eax
test   %al,%al
je     1170 <string_mod+0x50>
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1170 <string_mod+0x50>
mov    $0x1,%ebp
movb   $0x0,0x0(%r13)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Bytewerk/uClinux-ipcam/refs/heads/master/buffer.c\00"
define i32 @string_mod(i8* %0, i32 %1, i32 %2, i8 signext %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8 %3, i8* %8
%12 = load i8*, i8** %5
store i8* %12, i8** %9
store i32 1, i32* %10
br label %13
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @assert_failed(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 779)
br label %18
18: ; preds = %16, %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19, %44
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %9
%23 = load i8, i8* %21
store i8 %23, i8* %11
%24 = load i8, i8* %11
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %42
26: ; preds = %20
%27 = load i8, i8* %11
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @char_inc_exc(i8 signext %27, i32 %28, i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %26
%33 = load i8, i8* %8
store i8 %33, i8* %11
store i32 0, i32* %10
br label %34
34: ; preds = %32, %26
%35 = load i8, i8* %11
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i8, i8* %11
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
store i8 %38, i8* %39
br label %41
41: ; preds = %37, %34
br label %44
42: ; preds = %20
%43 = load i8*, i8** %5
store i8 0, i8* %43
br label %45
44: ; preds = %41
br label %20
45: ; preds = %42
%46 = load i32, i32* %10
ret i32 %46
}

LLVM IR (-O2):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Bytewerk/uClinux-ipcam/refs/heads/master/buffer.c\00"
define i32 @string_mod(i8* %0, i32 %1, i32 %2, i8 signext %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @assert_failed(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 779)
br label %8
8: ; preds = %6, %4
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %8, %24
%12 = phi i8 [ %26, %24 ], [ %9, %8 ]
%13 = phi i8* [ %16, %24 ], [ %0, %8 ]
%14 = phi i32 [ %19, %24 ], [ 1, %8 ]
%15 = phi i8* [ %25, %24 ], [ %0, %8 ]
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = tail call i32 @char_inc_exc(i8 signext %12, i32 %1, i32 %2)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 0, i32 %14
%20 = select i1 %18, i8 %3, i8 %12
%21 = icmp eq i8 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %11
%23 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %20, i8* %15
br label %24
24: ; preds = %22, %11
%25 = phi i8* [ %23, %22 ], [ %15, %11 ]
%26 = load i8, i8* %16
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %11
28: ; preds = %24, %8
%29 = phi i8* [ %0, %8 ], [ %25, %24 ]
%30 = phi i32 [ 1, %8 ], [ %19, %24 ]
store i8 0, i8* %29
ret i32 %30
}