#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*/ ft_bzero(char *, int);
int /*<<< orphan*/ ft_strdel(char **);
char *ft_strjoin(char *, char *);
size_t read(int const, char *, int);
int gnd_read(const int fd, char **stock) {
  size_t size;
  char buf[256 + 1];
  char *ptr;
  ft_bzero(buf, 256 + 1);
  ptr = *stock;
  size = read(fd, buf, 256);
  *stock = ft_strjoin(*stock, buf);
  ft_strdel(&ptr);
  return (size);
}


x86 assembly (clang, -O0):
<gnd_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x101,%esi
call   1030 <ft_bzero@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x128(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1040 <read@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x120(%rbp),%rsi
call   1060 <ft_strjoin@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x128(%rbp),%rdi
call   1050 <ft_strdel@plt>
mov    -0x18(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnd_read>:
push   %rbp
push   %r14
push   %rbx
sub    $0x120,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x101,%esi
call   1030 <ft_bzero@plt>
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x100,%edx
call   1040 <read@plt>
mov    %rax,%rbp
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1060 <ft_strjoin@plt>
mov    %rax,(%rbx)
lea    0x8(%rsp),%rdi
call   1050 <ft_strdel@plt>
mov    %ebp,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gnd_read(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca [257 x i8]
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%9 = call i32 @ft_bzero(i8* %8, i32 257)
%10 = load i8**, i8*** %4
%11 = load i8*, i8** %10
store i8* %11, i8** %7
%12 = load i32, i32* %3
%13 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%14 = call i64 @read(i32 %12, i8* %13, i32 256)
store i64 %14, i64* %5
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%18 = call i8* @ft_strjoin(i8* %16, i8* %17)
%19 = load i8**, i8*** %4
store i8* %18, i8** %19
%20 = call i32 @ft_strdel(i8** %7)
%21 = load i64, i64* %5
%22 = trunc i64 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
define i32 @gnd_read(i32 %0, i8** nocapture %1) {
%3 = alloca [257 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [257 x i8], [257 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = call i32 @ft_bzero(i8* %5, i32 257)
%8 = load i8*, i8** %1
store i8* %8, i8** %4
%9 = call i64 @read(i32 %0, i8* %5, i32 256)
%10 = load i8*, i8** %1
%11 = call i8* @ft_strjoin(i8* %10, i8* %5)
store i8* %11, i8** %1
%12 = call i32 @ft_strdel(i8** %4)
%13 = trunc i64 %9 to i32
ret i32 %13
}