#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printUsage();
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ writeLink(char *, int /*<<< orphan*/ *, int);
void printLink(char *html, char *txt) {
  FILE *fhtml = fopen(html, "r");
  FILE *ftxt = fopen(txt, "w");
  if ((fhtml == NULL) || (ftxt == NULL)) {
    printUsage();
  } else {
    fseek(fhtml, 1, SEEK_END);
    int size = ftell(fhtml);
    char *whtml = malloc(sizeof(char) * (size + 1));
    rewind(fhtml);
    if (whtml == NULL) {
      return;
    } else {
      fread(whtml, 1, size, fhtml);
      writeLink(whtml, ftxt, size);
      free(whtml);
    }
  }
  fclose(fhtml);
  fclose(ftxt);
}


x86 assembly (clang, -O0):
<printLink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ee <printLink+0x4e>
cmpq   $0x0,-0x20(%rbp)
jne    11fa <printLink+0x5a>
mov    $0x0,%al
call   10b0 <printUsage@plt>
jmp    1280 <printLink+0xe0>
mov    -0x18(%rbp),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
cmpq   $0x0,-0x30(%rbp)
jne    124d <printLink+0xad>
jmp    1292 <printLink+0xf2>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <writeLink@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1280 <printLink+0xe0>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLink>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
lea    0xe4d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r13
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r14
test   %r13,%r13
je     123c <printLink+0x9c>
test   %r14,%r14
je     123c <printLink+0x9c>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    $0x1,%esi
call   10a0 <fseek@plt>
mov    %r13,%rdi
call   1080 <ftell@plt>
mov    %eax,%r15d
lea    0x1(%r15),%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   1070 <rewind@plt>
test   %r12,%r12
je     125c <printLink+0xbc>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <writeLink@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    1243 <printLink+0xa3>
xor    %eax,%eax
call   10b0 <printUsage@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <fclose@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@SEEK_END = global i32 0
define void @printLink(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %5
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32*, i32** %6
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15, %2
%19 = call i32 (...) @printUsage()
br label %49
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i32, i32* @SEEK_END
%23 = call i32 @fseek(i32* %21, i32 1, i32 %22)
%24 = load i32*, i32** %5
%25 = call i32 @ftell(i32* %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 1, %28
%30 = trunc i64 %29 to i32
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %8
%32 = load i32*, i32** %5
%33 = call i32 @rewind(i32* %32)
%34 = load i8*, i8** %8
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %37
36: ; preds = %20
br label %54
37: ; preds = %20
%38 = load i8*, i8** %8
%39 = load i32, i32* %7
%40 = load i32*, i32** %5
%41 = call i32 @fread(i8* %38, i32 1, i32 %39, i32* %40)
%42 = load i8*, i8** %8
%43 = load i32*, i32** %6
%44 = load i32, i32* %7
%45 = call i32 @writeLink(i8* %42, i32* %43, i32 %44)
%46 = load i8*, i8** %8
%47 = call i32 @free(i8* %46)
br label %48
48: ; preds = %37
br label %49
49: ; preds = %48, %18
%50 = load i32*, i32** %5
%51 = call i32 @fclose(i32* %50)
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
br label %54
54: ; preds = %49, %36
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@SEEK_END = global i32 0
define void @printLink(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %3, null
%6 = icmp eq i32* %4, null
%7 = or i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (...) @printUsage()
br label %22
10: ; preds = %2
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @fseek(i32* %3, i32 1, i32 %11)
%13 = tail call i32 @ftell(i32* %3)
%14 = add nsw i32 %13, 1
%15 = tail call i8* @malloc(i32 %14)
%16 = tail call i32 @rewind(i32* %3)
%17 = icmp eq i8* %15, null
br i1 %17, label %25, label %18
18: ; preds = %10
%19 = tail call i32 @fread(i8* %15, i32 1, i32 %13, i32* %3)
%20 = tail call i32 @writeLink(i8* %15, i32* %4, i32 %13)
%21 = tail call i32 @free(i8* %15)
br label %22
22: ; preds = %18, %8
%23 = tail call i32 @fclose(i32* %3)
%24 = tail call i32 @fclose(i32* %4)
br label %25
25: ; preds = %10, %22
ret void
}