#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  int status, i;
  char buf[255], *p;
  FILE *infile, *outfile;
  if (argc != 3) {
    fprintf(stderr, "Usage: trimlib <infile> <outfile>\n");
    return -1;
  }
  if ((infile = fopen(argv[1], "rt")) == NULL) {
    printf("Unable to open input file!\n");
    exit(1);
  }
  if ((outfile = fopen(argv[2], "wt")) == NULL) {
    printf("Unable to open output file!\n");
    exit(1);
  }
  while (fgets(buf, 255, infile)) {
    if (strncmp(buf, "LIBR", 4) == 0) {
      p = &buf[4];
      while (isspace(*p) && *p != '\n')
        p++;
      if (*p == '\n' || *p == '\0')
        continue;
    }
    fputs(buf, outfile);
  }
  fclose(infile);
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d4 <main+0x44>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1370 <main+0x1e0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    120f <main+0x7f>
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe24(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
jne    124a <main+0xba>
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    124f <main+0xbf>
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0xff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1351 <main+0x1c1>
lea    -0x120(%rbp),%rdi
lea    0xde3(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1339 <main+0x1a9>
lea    -0x120(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x139(%rbp)
je     12df <main+0x14f>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    12f2 <main+0x162>
jmp    1309 <main+0x179>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    12a5 <main+0x115>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     132f <main+0x19f>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1334 <main+0x1a4>
jmp    124f <main+0xbf>
jmp    1339 <main+0x1a9>
lea    -0x120(%rbp),%rdi
mov    -0x138(%rbp),%rsi
call   1060 <fputs@plt>
jmp    124f <main+0xbf>
mov    -0x130(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x138(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x3,%edi
jne    1285 <main+0xf5>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe6b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12c5 <main+0x135>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
lea    0xe52(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12ce <main+0x13e>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12a1 <main+0x111>
lea    0x4(%rsp),%r13
lea    0xe1f(%rip),%r15
mov    %rsp,%rbx
jmp    1230 <main+0xa0>
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fputs@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12a1 <main+0x111>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1210 <main+0x80>
movsbl 0x4(%rsp),%edi
call   1070 <isspace@plt>
mov    %r13,%rbp
test   %rax,%rax
je     1278 <main+0xe8>
mov    %r13,%rbp
nopw   0x0(%rax,%rax,1)
cmpb   $0xa,0x0(%rbp)
je     121b <main+0x8b>
movsbl 0x1(%rbp),%edi
add    $0x1,%rbp
call   1070 <isspace@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    0x0(%rbp),%al
cmp    $0xa,%al
je     121b <main+0x8b>
test   %al,%al
je     121b <main+0x8b>
jmp    1210 <main+0x80>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd6b(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    12b3 <main+0x123>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd7e(%rip),%rdi
jmp    12d5 <main+0x145>
lea    0xd59(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: trimlib <infile> <outfile>\0A\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [28 x i8] c"Unable to open input file!\0A\00"
@.str.3 = [3 x i8] c"wt\00"
@.str.4 = [29 x i8] c"Unable to open output file!\0A\00"
@.str.5 = [5 x i8] c"LIBR\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [255 x i8]
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %83
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %10
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %30, i32** %11
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %26
br label %36
36: ; preds = %74, %72, %35
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%38 = load i32*, i32** %10
%39 = call i64 @fgets(i8* %37, i32 255, i32* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %78
41: ; preds = %36
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %74
45: ; preds = %41
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 4
store i8* %46, i8** %9
br label %47
47: ; preds = %59, %45
%48 = load i8*, i8** %9
%49 = load i8, i8* %48
%50 = call i64 @isspace(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %47
%53 = load i8*, i8** %9
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 10
br label %57
57: ; preds = %52, %47
%58 = phi i1 [ false, %47 ], [ %56, %52 ]
br i1 %58, label %59, label %62
59: ; preds = %57
%60 = load i8*, i8** %9
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %9
br label %47
62: ; preds = %57
%63 = load i8*, i8** %9
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %72, label %67
67: ; preds = %62
%68 = load i8*, i8** %9
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %67, %62
br label %36
73: ; preds = %67
br label %74
74: ; preds = %73, %41
%75 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%76 = load i32*, i32** %11
%77 = call i32 @fputs(i8* %75, i32* %76)
br label %36
78: ; preds = %36
%79 = load i32*, i32** %10
%80 = call i32 @fclose(i32* %79)
%81 = load i32*, i32** %11
%82 = call i32 @fclose(i32* %81)
store i32 0, i32* %3
br label %83
83: ; preds = %78, %14
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: trimlib <infile> <outfile>\0A\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.3 = [3 x i8] c"wt\00"
@.str.5 = [5 x i8] c"LIBR\00"
@str = [28 x i8] c"Unable to open output file!\00"
@str.6 = [27 x i8] c"Unable to open input file!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %57
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = call i64 @fgets(i8* %4, i32 255, i32* %12)
%24 = icmp eq i64 %23, 0
br i1 %24, label %54, label %25
25: ; preds = %22
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 4
br label %30
27: ; preds = %17
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %25, %49
%31 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %52
33: ; preds = %30
%34 = load i8, i8* %26
%35 = call i64 @isspace(i8 signext %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %46, label %37
37: ; preds = %33, %41
%38 = phi i8* [ %42, %41 ], [ %26, %33 ]
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 10
br i1 %40, label %49, label %41
41: ; preds = %37
%42 = getelementptr inbounds i8, i8* %38, i64 1
%43 = load i8, i8* %42
%44 = call i64 @isspace(i8 signext %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %37
46: ; preds = %41, %33
%47 = phi i8* [ %26, %33 ], [ %42, %41 ]
%48 = load i8, i8* %47
switch i8 %48, label %52 [
i8 10, label %49
i8 0, label %49
]
49: ; preds = %37, %46, %46, %52
%50 = call i64 @fgets(i8* %4, i32 255, i32* %12)
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %30
52: ; preds = %46, %30
%53 = call i32 @fputs(i8* %4, i32* %20)
br label %49
54: ; preds = %49, %22
%55 = call i32 @fclose(i32* %12)
%56 = call i32 @fclose(i32* %20)
br label %57
57: ; preds = %54, %6
%58 = phi i32 [ -1, %6 ], [ 0, %54 ]
ret i32 %58
}