#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int buscaIdCapturado(int /*<<< orphan*/ *, int, char *, int, int);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char *);
int removeRegCapturado(FILE *arquivo, int id_ind, char data[], int off,
                       int offset_inicial) {
  int offset = buscaIdCapturado(arquivo, id_ind, data, off, offset_inicial);
  char pipe[] = "$";
  if (offset == -1) {
    return 0;
  } else {
    offset += 2;
    fseek(arquivo, offset, SEEK_SET);
    fwrite(pipe, 1, strlen(pipe), arquivo);
    return 1;
  }
}


x86 assembly (clang, -O0):
<removeRegCapturado>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1040 <buscaIdCapturado@plt>
mov    %eax,-0x2c(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x2e(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1195 <removeRegCapturado+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11df <removeRegCapturado+0x9f>
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    0x2e34(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
lea    -0x2e(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x2e(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fwrite@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeRegCapturado>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <buscaIdCapturado@plt>
movw   $0x24,0xe(%rsp)
cmp    $0xffffffff,%eax
je     1198 <removeRegCapturado+0x58>
add    $0x2,%eax
mov    0x2e7a(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <fseek@plt>
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
jmp    119a <removeRegCapturado+0x5a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.removeRegCapturado.pipe = [2 x i8] c"$\00"
@SEEK_SET = global i32 0
define i32 @removeRegCapturado(i32* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [2 x i8]
store i32* %0, i32** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i32*, i32** %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %9
%17 = load i32, i32* %10
%18 = load i32, i32* %11
%19 = call i32 @buscaIdCapturado(i32* %14, i32 %15, i8* %16, i32 %17, i32 %18)
store i32 %19, i32* %12
%20 = bitcast [2 x i8]* %13 to i8*
%21 = load i32, i32* %12
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %5
store i32 0, i32* %6
br label %36
24: ; preds = %5
%25 = load i32, i32* %12
%26 = add nsw i32 %25, 2
store i32 %26, i32* %12
%27 = load i32*, i32** %7
%28 = load i32, i32* %12
%29 = load i32, i32* @SEEK_SET
%30 = call i32 @fseek(i32* %27, i32 %28, i32 %29)
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%32 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = load i32*, i32** %7
%35 = call i32 @fwrite(i8* %31, i32 1, i32 %33, i32* %34)
store i32 1, i32* %6
br label %36
36: ; preds = %24, %23
%37 = load i32, i32* %6
ret i32 %37
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @removeRegCapturado(i32* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i16
%7 = tail call i32 @buscaIdCapturado(i32* %0, i32 %1, i8* %2, i32 %3, i32 %4)
%8 = bitcast i16* %6 to i8*
store i16 36, i16* %6
%9 = icmp eq i32 %7, -1
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = add nsw i32 %7, 2
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @fseek(i32* %0, i32 %11, i32 %12)
%14 = call i32 @strlen(i8* %8)
%15 = call i32 @fwrite(i8* %8, i32 1, i32 %14, i32* %0)
br label %16
16: ; preds = %5, %10
%17 = phi i32 [ 1, %10 ], [ 0, %5 ]
ret i32 %17
}