#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*/ copy_binary(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               char *);
int /*<<< orphan*/ copy_data(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int dsc_copy_section(FILE *from, FILE *to, long start, long end, char *line,
                     const char *sentinel) {
  int sent_len = (sentinel == 0 ? 0 : strlen(sentinel));
  if (start >= 0)
    fseek(from, start, 0);
  while (ftell(from) < end) {
    long count;
    fgets(line, 258, from);
    if (sent_len) {
      if (!strncmp(line, sentinel, sent_len))
        return 1;
    }
    fputs(line, to);
    if (!(((line)[0] == '%' && (line)[1] == '%') &&
          !strncmp(line, "Begin", sizeof("Begin") - 1)))
      ;
    else if (!strncmp(line + 7, "Binary:", sizeof("Binary:") - 1))
      copy_binary(to, from, line);
    else if (!strncmp(line + 7, "Data:", sizeof("Data:") - 1))
      copy_data(to, from, line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<dsc_copy_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11b5 <dsc_copy_section+0x35>
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c1 <dsc_copy_section+0x41>
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpq   $0x0,-0x20(%rbp)
jl     11e1 <dsc_copy_section+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   10a0 <fseek@plt>
jmp    11e6 <dsc_copy_section+0x66>
mov    -0x10(%rbp),%rdi
call   1080 <ftell@plt>
cmp    -0x28(%rbp),%rax
jge    130a <dsc_copy_section+0x18a>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x102,%esi
call   1070 <fgets@plt>
cmpl   $0x0,-0x3c(%rbp)
je     123f <dsc_copy_section+0xbf>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    123a <dsc_copy_section+0xba>
movl   $0x1,-0x4(%rbp)
jmp    1311 <dsc_copy_section+0x191>
jmp    123f <dsc_copy_section+0xbf>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    128b <dsc_copy_section+0x10b>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x25,%eax
jne    128b <dsc_copy_section+0x10b>
mov    -0x30(%rbp),%rdi
lea    0xd88(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     1290 <dsc_copy_section+0x110>
jmp    1305 <dsc_copy_section+0x185>
mov    -0x30(%rbp),%rdi
add    $0x7,%rdi
lea    0xd67(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12c8 <dsc_copy_section+0x148>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <copy_binary@plt>
jmp    1300 <dsc_copy_section+0x180>
mov    -0x30(%rbp),%rdi
add    $0x7,%rdi
lea    0xd37(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12fb <dsc_copy_section+0x17b>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1090 <copy_data@plt>
jmp    1300 <dsc_copy_section+0x180>
jmp    1305 <dsc_copy_section+0x185>
jmp    11e6 <dsc_copy_section+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsc_copy_section>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
test   %r9,%r9
je     11e7 <dsc_copy_section+0x67>
mov    %r14,%rdi
mov    %rdx,%rbp
call   1050 <strlen@plt>
mov    %rbp,%rdx
mov    %eax,%ebp
test   %rdx,%rdx
js     11c4 <dsc_copy_section+0x44>
mov    %r13,%rdi
mov    %rdx,%rsi
xor    %edx,%edx
call   10a0 <fseek@plt>
mov    %r13,%rdi
call   1080 <ftell@plt>
xor    %ecx,%ecx
cmp    %r15,%rax
jge    12d6 <dsc_copy_section+0x156>
lea    0x7(%rbx),%rax
mov    %rax,0x10(%rsp)
mov    %r14,0x8(%rsp)
jmp    1221 <dsc_copy_section+0xa1>
xor    %ebp,%ebp
test   %rdx,%rdx
jns    11b7 <dsc_copy_section+0x37>
jmp    11c4 <dsc_copy_section+0x44>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1030 <copy_binary@plt>
mov    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1080 <ftell@plt>
cmp    %r15,%rax
jge    12cd <dsc_copy_section+0x14d>
mov    %rbx,%rdi
mov    $0x102,%esi
mov    %r13,%rdx
call   1070 <fgets@plt>
test   %ebp,%ebp
je     124a <dsc_copy_section+0xca>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     12d1 <dsc_copy_section+0x151>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <fputs@plt>
cmpb   $0x25,(%rbx)
jne    1210 <dsc_copy_section+0x90>
cmpb   $0x25,0x1(%rbx)
jne    1210 <dsc_copy_section+0x90>
mov    %rbx,%rdi
lea    0xd96(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1210 <dsc_copy_section+0x90>
mov    0x10(%rsp),%r14
mov    %r14,%rdi
lea    0xd7f(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     11f0 <dsc_copy_section+0x70>
mov    %r14,%rdi
lea    0xd6b(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
mov    0x8(%rsp),%r14
jne    1210 <dsc_copy_section+0x90>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1090 <copy_data@plt>
jmp    1210 <dsc_copy_section+0x90>
xor    %ecx,%ecx
jmp    12d6 <dsc_copy_section+0x156>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Begin\00"
@.str.1 = [8 x i8] c"Binary:\00"
@.str.2 = [6 x i8] c"Data:\00"
define i32 @dsc_copy_section(i32* %0, i32* %1, i64 %2, i64 %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i64
store i32* %0, i32** %8
store i32* %1, i32** %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%16 = load i8*, i8** %13
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %6
br label %22
19: ; preds = %6
%20 = load i8*, i8** %13
%21 = call i32 @strlen(i8* %20)
br label %22
22: ; preds = %19, %18
%23 = phi i32 [ 0, %18 ], [ %21, %19 ]
store i32 %23, i32* %14
%24 = load i64, i64* %10
%25 = icmp sge i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32*, i32** %8
%28 = load i64, i64* %10
%29 = call i32 @fseek(i32* %27, i64 %28, i32 0)
br label %30
30: ; preds = %26, %22
br label %31
31: ; preds = %92, %30
%32 = load i32*, i32** %8
%33 = call i64 @ftell(i32* %32)
%34 = load i64, i64* %11
%35 = icmp slt i64 %33, %34
br i1 %35, label %36, label %93
36: ; preds = %31
%37 = load i8*, i8** %12
%38 = load i32*, i32** %8
%39 = call i32 @fgets(i8* %37, i32 258, i32* %38)
%40 = load i32, i32* %14
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %36
%43 = load i8*, i8** %12
%44 = load i8*, i8** %13
%45 = load i32, i32* %14
%46 = call i32 @strncmp(i8* %43, i8* %44, i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %42
store i32 1, i32* %7
br label %94
49: ; preds = %42
br label %50
50: ; preds = %49, %36
%51 = load i8*, i8** %12
%52 = load i32*, i32** %9
%53 = call i32 @fputs(i8* %51, i32* %52)
%54 = load i8*, i8** %12
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 37
br i1 %58, label %59, label %69
59: ; preds = %50
%60 = load i8*, i8** %12
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 37
br i1 %64, label %65, label %69
65: ; preds = %59
%66 = load i8*, i8** %12
%67 = call i32 @strncmp(i8* %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %65, %59, %50
br label %92
70: ; preds = %65
%71 = load i8*, i8** %12
%72 = getelementptr inbounds i8, i8* %71, i64 7
%73 = call i32 @strncmp(i8* %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%74 = icmp ne i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %70
%76 = load i32*, i32** %9
%77 = load i32*, i32** %8
%78 = load i8*, i8** %12
%79 = call i32 @copy_binary(i32* %76, i32* %77, i8* %78)
br label %91
80: ; preds = %70
%81 = load i8*, i8** %12
%82 = getelementptr inbounds i8, i8* %81, i64 7
%83 = call i32 @strncmp(i8* %82, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%84 = icmp ne i32 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = load i32*, i32** %9
%87 = load i32*, i32** %8
%88 = load i8*, i8** %12
%89 = call i32 @copy_data(i32* %86, i32* %87, i8* %88)
br label %90
90: ; preds = %85, %80
br label %91
91: ; preds = %90, %75
br label %92
92: ; preds = %91, %69
br label %31
93: ; preds = %31
store i32 0, i32* %7
br label %94
94: ; preds = %93, %48
%95 = load i32, i32* %7
ret i32 %95
}

LLVM IR (-O2):
@.str = [6 x i8] c"Begin\00"
@.str.1 = [8 x i8] c"Binary:\00"
@.str.2 = [6 x i8] c"Data:\00"
define i32 @dsc_copy_section(i32* %0, i32* %1, i64 %2, i64 %3, i8* %4, i8* %5) {
%7 = icmp eq i8* %5, null
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @strlen(i8* %5)
br label %10
10: ; preds = %6, %8
%11 = phi i32 [ %9, %8 ], [ 0, %6 ]
%12 = icmp sgt i64 %2, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @fseek(i32* %0, i64 %2, i32 0)
br label %15
15: ; preds = %13, %10
%16 = tail call i64 @ftell(i32* %0)
%17 = icmp slt i64 %16, %3
br i1 %17, label %18, label %50
18: ; preds = %15
%19 = icmp eq i32 %11, 0
%20 = getelementptr inbounds i8, i8* %4, i64 1
%21 = getelementptr inbounds i8, i8* %4, i64 7
br label %22
22: ; preds = %18, %47
%23 = tail call i32 @fgets(i8* %4, i32 258, i32* %0)
br i1 %19, label %27, label %24
24: ; preds = %22
%25 = tail call i32 @strncmp(i8* %4, i8* %5, i32 %11)
%26 = icmp eq i32 %25, 0
br i1 %26, label %50, label %27
27: ; preds = %24, %22
%28 = tail call i32 @fputs(i8* %4, i32* %1)
%29 = load i8, i8* %4
%30 = icmp eq i8 %29, 37
br i1 %30, label %31, label %47
31: ; preds = %27
%32 = load i8, i8* %20
%33 = icmp eq i8 %32, 37
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = tail call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %34
%38 = tail call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = tail call i32 @copy_binary(i32* %1, i32* %0, i8* %4)
br label %47
42: ; preds = %37
%43 = tail call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 @copy_data(i32* %1, i32* %0, i8* %4)
br label %47
47: ; preds = %34, %31, %27, %42, %45, %40
%48 = tail call i64 @ftell(i32* %0)
%49 = icmp slt i64 %48, %3
br i1 %49, label %22, label %50
50: ; preds = %47, %24, %15
%51 = phi i32 [ 0, %15 ], [ 1, %24 ], [ 0, %47 ]
ret i32 %51
}