#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*/ free(char *);
int /*<<< orphan*/ ft_strdel(char **);
char *ft_strdup(char *);
char *ft_strjoin(char *, char *);
int ft_strlen(char *);
scalar_t__ realloc_str(char **, int);
int process_read(char **line_copy, char **buffer) {
  int line_len;
  int buffer_len;
  char *temp;
  line_len = ft_strlen(*line_copy);
  buffer_len = ft_strlen(*buffer);
  if (!*line_copy || (realloc_str(line_copy, (line_len + buffer_len + 1))) ||
      !(temp = ft_strjoin(*line_copy, *buffer)))
    return (-1);
  free(*line_copy);
  *line_copy = ft_strdup(temp);
  free(temp);
  ft_strdel(buffer);
  return (0);
}


x86 assembly (clang, -O0):
<process_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ft_strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ft_strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d9 <process_read+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    -0x20(%rbp),%esi
add    $0x1,%esi
call   1080 <realloc_str@plt>
cmp    $0x0,%rax
jne    11d9 <process_read+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1070 <ft_strjoin@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11e5 <process_read+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    121d <process_read+0xbd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1060 <ft_strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ft_strdel@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_read>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1040 <ft_strlen@plt>
mov    %eax,%ebp
mov    (%r14),%rdi
call   1040 <ft_strlen@plt>
mov    $0xffffffff,%r12d
cmpq   $0x0,(%rbx)
je     11d8 <process_read+0x78>
lea    (%rax,%rbp,1),%esi
add    $0x1,%esi
mov    %rbx,%rdi
call   1080 <realloc_str@plt>
test   %rax,%rax
jne    11d8 <process_read+0x78>
mov    (%rbx),%rdi
mov    (%r14),%rsi
call   1070 <ft_strjoin@plt>
test   %rax,%rax
je     11d8 <process_read+0x78>
mov    %rax,%r15
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <ft_strdup@plt>
mov    %rax,(%rbx)
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <ft_strdel@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @process_read(i8** %0, i8** %1) {
%3 = alloca i32
%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 = load i8*, i8** %9
%11 = call i32 @ft_strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = call i32 @ft_strlen(i8* %13)
store i32 %14, i32* %7
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %33
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = add nsw i32 %20, %21
%23 = add nsw i32 %22, 1
%24 = call i64 @realloc_str(i8** %19, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %18
%27 = load i8**, i8*** %4
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = load i8*, i8** %29
%31 = call i8* @ft_strjoin(i8* %28, i8* %30)
store i8* %31, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %34, label %33
33: ; preds = %26, %18, %2
store i32 -1, i32* %3
br label %45
34: ; preds = %26
%35 = load i8**, i8*** %4
%36 = load i8*, i8** %35
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %8
%39 = call i8* @ft_strdup(i8* %38)
%40 = load i8**, i8*** %4
store i8* %39, i8** %40
%41 = load i8*, i8** %8
%42 = call i32 @free(i8* %41)
%43 = load i8**, i8*** %5
%44 = call i32 @ft_strdel(i8** %43)
store i32 0, i32* %3
br label %45
45: ; preds = %34, %33
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @process_read(i8** %0, i8** %1) {
%3 = load i8*, i8** %0
%4 = tail call i32 @ft_strlen(i8* %3)
%5 = load i8*, i8** %1
%6 = tail call i32 @ft_strlen(i8* %5)
%7 = load i8*, i8** %0
%8 = icmp eq i8* %7, null
br i1 %8, label %25, label %9
9: ; preds = %2
%10 = add i32 %4, 1
%11 = add i32 %10, %6
%12 = tail call i64 @realloc_str(i8** %0, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = load i8*, i8** %0
%16 = load i8*, i8** %1
%17 = tail call i8* @ft_strjoin(i8* %15, i8* %16)
%18 = icmp eq i8* %17, null
br i1 %18, label %25, label %19
19: ; preds = %14
%20 = load i8*, i8** %0
%21 = tail call i32 @free(i8* %20)
%22 = tail call i8* @ft_strdup(i8* %17)
store i8* %22, i8** %0
%23 = tail call i32 @free(i8* %17)
%24 = tail call i32 @ft_strdel(i8** %1)
br label %25
25: ; preds = %2, %9, %14, %19
%26 = phi i32 [ 0, %19 ], [ -1, %14 ], [ -1, %9 ], [ -1, %2 ]
ret i32 %26
}