#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void tplt_xfer(FILE *in, FILE *out, int *lineno) {
  int iStart;
  char line[1000];
  while (fgets(line, 1000, in) && (line[0] != '%' || line[1] != '%')) {
    (*lineno)++;
    iStart = 0;
    fprintf(out, "%s", &line[iStart]);
  }
}


x86 assembly (clang, -O0):
<tplt_xfer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e8,%esi
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x411(%rbp)
je     1198 <tplt_xfer+0x78>
movsbl -0x410(%rbp),%ecx
mov    $0x1,%al
cmp    $0x25,%ecx
mov    %al,-0x412(%rbp)
jne    118c <tplt_xfer+0x6c>
movsbl -0x40f(%rbp),%eax
cmp    $0x25,%eax
setne  %al
mov    %al,-0x412(%rbp)
mov    -0x412(%rbp),%al
mov    %al,-0x411(%rbp)
mov    -0x411(%rbp),%al
test   $0x1,%al
jne    11ab <tplt_xfer+0x8b>
jmp    11e0 <tplt_xfer+0xc0>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
lea    -0x410(%rbp),%rdx
add    %rax,%rdx
lea    0xe2a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1137 <tplt_xfer+0x17>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tplt_xfer>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1191 <tplt_xfer+0x71>
mov    %rsp,%rbx
jmp    1184 <tplt_xfer+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addl   $0x1,(%r14)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1191 <tplt_xfer+0x71>
cmpb   $0x25,(%rsp)
jne    1160 <tplt_xfer+0x40>
cmpb   $0x25,0x1(%rsp)
jne    1160 <tplt_xfer+0x40>
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @tplt_xfer(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [1000 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
br label %9
9: ; preds = %28, %3
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i64 @fgets(i8* %10, i32 1000, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 37
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 37
br label %24
24: ; preds = %19, %14
%25 = phi i1 [ true, %14 ], [ %23, %19 ]
br label %26
26: ; preds = %24, %9
%27 = phi i1 [ false, %9 ], [ %25, %24 ]
br i1 %27, label %28, label %37
28: ; preds = %26
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
store i32 0, i32* %7
%32 = load i32*, i32** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 %34
%36 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %9
37: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @tplt_xfer(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = call i64 @fgets(i8* %5, i32 1000, i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %3
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 1
br label %10
10: ; preds = %8, %16
%11 = load i8, i8* %5
%12 = icmp ne i8 %11, 37
%13 = load i8, i8* %9
%14 = icmp ne i8 %13, 37
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
%19 = call i32 @fputs(i8* %5, i32* %1)
%20 = call i64 @fgets(i8* %5, i32 1000, i32* %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %10
22: ; preds = %10, %16, %3
ret void
}