#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 */
char *_find_digit(char *, size_t, char);
int /*<<< orphan*/ memmove(char *, char *, size_t);
int _sub_digit(char *buf, size_t buf_len, char digit) {
  char *l = _find_digit(buf, buf_len, digit);
  if (!l) {
    return 1;
  }
  memmove(l, l + sizeof(char), buf_len - (l - buf) - sizeof(char));
  return 0;
}


x86 assembly (clang, -O0):
<_sub_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsbl -0x19(%rbp),%edx
call   1030 <_find_digit@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1161 <_sub_digit+0x41>
movl   $0x1,-0x4(%rbp)
jmp    118f <_sub_digit+0x6f>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sub    %rax,%rdx
sub    $0x1,%rdx
call   1040 <memmove@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sub_digit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <_find_digit@plt>
test   %rax,%rax
je     1150 <_sub_digit+0x30>
lea    0x1(%rax),%rsi
add    %r14,%rbx
mov    %rax,%rdx
not    %rdx
add    %rbx,%rdx
mov    %rax,%rdi
call   1040 <memmove@plt>
xor    %eax,%eax
jmp    1155 <_sub_digit+0x35>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @_sub_digit(i8* %0, i64 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8
%8 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8 %2, i8* %7
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = load i8, i8* %7
%12 = call i8* @_find_digit(i8* %9, i64 %10, i8 signext %11)
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i32 1, i32* %4
br label %29
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i64, i64* %6
%21 = load i8*, i8** %8
%22 = load i8*, i8** %5
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = sub i64 %20, %25
%27 = sub i64 %26, 1
%28 = call i32 @memmove(i8* %17, i8* %19, i64 %27)
store i32 0, i32* %4
br label %29
29: ; preds = %16, %15
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @_sub_digit(i8* %0, i64 %1, i8 signext %2) {
%4 = tail call i8* @_find_digit(i8* %0, i64 %1, i8 signext %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = ptrtoint i8* %4 to i64
%9 = ptrtoint i8* %0 to i64
%10 = add i64 %9, -1
%11 = add i64 %10, %1
%12 = sub i64 %11, %8
%13 = tail call i32 @memmove(i8* %4, i8* %7, i64 %12)
br label %14
14: ; preds = %3, %6
%15 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %15
}