#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void ProcessFiles(FILE *in, FILE *out) {
  char line[1000];
  char *match1 = "Ligature: 8", *match2 = "Ligature: 9";
  int matchlen = strlen(match1);
  while (fgets(line, sizeof(line), in) != NULL) {
    if (strncmp(line, match1, matchlen) == 0)
      line[matchlen - 1] = '0';
    else if (strncmp(line, match2, matchlen) == 0)
      line[matchlen - 1] = '1';
    fputs(line, out);
  }
}


x86 assembly (clang, -O0):
<ProcessFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x408(%rbp)
lea    0xea4(%rip),%rax
mov    %rax,-0x410(%rbp)
mov    -0x408(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x414(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     122b <ProcessFiles+0xeb>
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%rsi
mov    -0x414(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11db <ProcessFiles+0x9b>
mov    -0x414(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x30,-0x400(%rbp,%rax,1)
30
jmp    1216 <ProcessFiles+0xd6>
lea    -0x400(%rbp),%rdi
mov    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1211 <ProcessFiles+0xd1>
mov    -0x414(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x31,-0x400(%rbp,%rax,1)
31
jmp    1216 <ProcessFiles+0xd6>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fputs@plt>
jmp    1181 <ProcessFiles+0x41>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessFiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xea2(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e3 <ProcessFiles+0xa3>
movslq %ebp,%r13
lea    0xe7c(%rip),%r15
mov    %rsp,%rbx
jmp    11b7 <ProcessFiles+0x77>
nopl   0x0(%rax)
mov    $0x30,%al
mov    %al,-0x1(%rsp,%r13,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e3 <ProcessFiles+0xa3>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1190 <ProcessFiles+0x50>
mov    %rbx,%rdi
lea    0xe39(%rip),%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1197 <ProcessFiles+0x57>
mov    $0x31,%al
jmp    1192 <ProcessFiles+0x52>
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Ligature: 8\00"
@.str.1 = [12 x i8] c"Ligature: 9\00"
define void @ProcessFiles(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1000 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %7
%9 = load i8*, i8** %6
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %8
br label %11
11: ; preds = %39, %2
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%13 = load i32*, i32** %3
%14 = call i32* @fgets(i8* %12, i32 1000, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %43
16: ; preds = %11
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = load i32, i32* %8
%20 = call i64 @strncmp(i8* %17, i8* %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %25
store i8 48, i8* %26
br label %39
27: ; preds = %16
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = call i64 @strncmp(i8* %28, i8* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i32, i32* %8
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %36
store i8 49, i8* %37
br label %38
38: ; preds = %33, %27
br label %39
39: ; preds = %38, %22
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%41 = load i32*, i32** %4
%42 = call i32 @fputs(i8* %40, i32* %41)
br label %11
43: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Ligature: 8\00"
@.str.1 = [12 x i8] c"Ligature: 9\00"
define void @ProcessFiles(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i32* @fgets(i8* %4, i32 1000, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %24, label %8
8: ; preds = %2
%9 = add nsw i32 %5, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %10
br label %12
12: ; preds = %8, %20
%13 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %12
%19 = phi i8 [ 48, %12 ], [ 49, %15 ]
store i8 %19, i8* %11
br label %20
20: ; preds = %18, %15
%21 = call i32 @fputs(i8* %4, i32* %1)
%22 = call i32* @fgets(i8* %4, i32 1000, i32* %0)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %12
24: ; preds = %20, %2
ret void
}