#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 *);
char *ft_strdup(char *);
void load_line(char **line, char **remaining, char *found) {
  char *tmp;
  *line = ft_strdup(*remaining);
  if (found) {
    tmp = *remaining;
    *remaining = ft_strdup(found + 1);
    free(tmp);
  } else
    *remaining = NULL;
}


x86 assembly (clang, -O0):
<load_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ft_strdup@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1185 <load_line+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1040 <ft_strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1190 <load_line+0x70>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_line>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%rdi
call   1040 <ft_strdup@plt>
mov    %rax,(%r15)
test   %rbx,%rbx
je     115d <load_line+0x3d>
mov    (%r14),%r15
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <ft_strdup@plt>
mov    %rax,(%r14)
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
movq   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @load_line(i8** %0, i8** %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = call i8* @ft_strdup(i8* %9)
%11 = load i8**, i8*** %4
store i8* %10, i8** %11
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %3
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i8* @ft_strdup(i8* %18)
%20 = load i8**, i8*** %5
store i8* %19, i8** %20
%21 = load i8*, i8** %7
%22 = call i32 @free(i8* %21)
br label %25
23: ; preds = %3
%24 = load i8**, i8*** %5
store i8* null, i8** %24
br label %25
25: ; preds = %23, %14
ret void
}

LLVM IR (-O2):
define void @load_line(i8** nocapture writeonly %0, i8** nocapture %1, i8* %2) {
%4 = load i8*, i8** %1
%5 = tail call i8* @ft_strdup(i8* %4)
store i8* %5, i8** %0
%6 = icmp eq i8* %2, null
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i8*, i8** %1
%9 = getelementptr inbounds i8, i8* %2, i64 1
%10 = tail call i8* @ft_strdup(i8* %9)
store i8* %10, i8** %1
%11 = tail call i32 @free(i8* %8)
br label %13
12: ; preds = %3
store i8* null, i8** %1
br label %13
13: ; preds = %12, %7
ret void
}