#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*/ fputs(char *, int /*<<< orphan*/ *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void CopyTmplProlog(FILE *tmpl, FILE *f) {
  char buf[1024];
  static char *magic_string = "<<<STRING_TABLE_GOES_HERE>>>";
  int magic_string_len = strlen(magic_string);
  while (fgets(buf, sizeof buf, tmpl)) {
    if (strncmp(buf, magic_string, magic_string_len) == 0) {
      return;
    }
    (void)fputs(buf, f);
  }
}


x86 assembly (clang, -O0):
<CopyTmplProlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ee6(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11c1 <CopyTmplProlog+0x81>
lea    -0x410(%rbp),%rdi
mov    0x2eae(%rip),%rsi
mov    -0x414(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ac <CopyTmplProlog+0x6c>
jmp    11c1 <CopyTmplProlog+0x81>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fputs@plt>
jmp    1165 <CopyTmplProlog+0x25>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyTmplProlog>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xea4(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c2 <CopyTmplProlog+0x82>
lea    0xe81(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c2 <CopyTmplProlog+0x82>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1190 <CopyTmplProlog+0x50>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CopyTmplProlog.magic_string = internal global i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i32 0, i32 0)
@.str = [29 x i8] c"<<<STRING_TABLE_GOES_HERE>>>\00"
define void @CopyTmplProlog(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i8*, i8** @CopyTmplProlog.magic_string
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
br label %9
9: ; preds = %21, %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = load i32*, i32** %3
%12 = call i64 @fgets(i8* %10, i32 1024, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** @CopyTmplProlog.magic_string
%17 = load i32, i32* %6
%18 = call i64 @strncmp(i8* %15, i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
br label %25
21: ; preds = %14
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = load i32*, i32** %4
%24 = call i32 @fputs(i8* %22, i32* %23)
br label %9
25: ; preds = %20, %9
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"<<<STRING_TABLE_GOES_HERE>>>\00"
define void @CopyTmplProlog(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @fgets(i8* %4, i32 1024, i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %2, %11
%9 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = call i32 @fputs(i8* %4, i32* %1)
%13 = call i64 @fgets(i8* %4, i32 1024, i32* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %8
15: ; preds = %8, %11, %2
ret void
}