#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 dsc_copy_section(int /*<<< orphan*/ *, int /*<<< orphan*/ *, long, long,
                     char *, char const *);
char *dsc_malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *dsc_copy_until(FILE *from, FILE *to, long start, long end,
                     const char *sentinel) {
  char line[258];
  int found = dsc_copy_section(from, to, start, end, line, sentinel);
  if (found) {
    char *ret = dsc_malloc(strlen(line) + 1);
    strcpy(ret, line);
    return ret;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<dsc_copy_until>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x140(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1060 <dsc_copy_section@plt>
mov    %eax,-0x144(%rbp)
cmpl   $0x0,-0x144(%rbp)
je     11d4 <dsc_copy_until+0x94>
lea    -0x140(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <dsc_malloc@plt>
mov    %rax,-0x150(%rbp)
mov    -0x150(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x150(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11dc <dsc_copy_until+0x9c>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsc_copy_until>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %r8,%r9
mov    %rsp,%r8
call   1060 <dsc_copy_section@plt>
test   %eax,%eax
je     117d <dsc_copy_until+0x3d>
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <dsc_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    117f <dsc_copy_until+0x3f>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @dsc_copy_until(i32* %0, i32* %1, i64 %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca [258 x i8]
%13 = alloca i32
%14 = alloca i8*
store i32* %0, i32** %7
store i32* %1, i32** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i8* %4, i8** %11
%15 = load i32*, i32** %7
%16 = load i32*, i32** %8
%17 = load i64, i64* %9
%18 = load i64, i64* %10
%19 = getelementptr inbounds [258 x i8], [258 x i8]* %12, i64 0, i64 0
%20 = load i8*, i8** %11
%21 = call i32 @dsc_copy_section(i32* %15, i32* %16, i64 %17, i64 %18, i8* %19, i8* %20)
store i32 %21, i32* %13
%22 = load i32, i32* %13
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %5
%25 = getelementptr inbounds [258 x i8], [258 x i8]* %12, i64 0, i64 0
%26 = call i64 @strlen(i8* %25)
%27 = add nsw i64 %26, 1
%28 = call i8* @dsc_malloc(i64 %27)
store i8* %28, i8** %14
%29 = load i8*, i8** %14
%30 = getelementptr inbounds [258 x i8], [258 x i8]* %12, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %14
store i8* %32, i8** %6
br label %34
33: ; preds = %5
store i8* null, i8** %6
br label %34
34: ; preds = %33, %24
%35 = load i8*, i8** %6
ret i8* %35
}

LLVM IR (-O2):
define i8* @dsc_copy_until(i32* %0, i32* %1, i64 %2, i64 %3, i8* %4) {
%6 = alloca [258 x i8]
%7 = getelementptr inbounds [258 x i8], [258 x i8]* %6, i64 0, i64 0
%8 = call i32 @dsc_copy_section(i32* %0, i32* %1, i64 %2, i64 %3, i8* %7, i8* %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = call i64 @strlen(i8* %7)
%12 = add nsw i64 %11, 1
%13 = call i8* @dsc_malloc(i64 %12)
%14 = call i32 @strcpy(i8* %13, i8* %7)
br label %15
15: ; preds = %5, %10
%16 = phi i8* [ %13, %10 ], [ null, %5 ]
ret i8* %16
}