#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*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  FILE *file_1;
  FILE *file_2;
  char *name_1;
  char *name_2;
  int data = 0;
  int buf = 0;
  printf("%s by DE\n", argv[0]);
  if (argc < 3) {
    printf("usage: %s infile outfile\n", argv[0]);
    exit(1);
  }
  name_1 = argv[1];
  name_2 = argv[2];
  file_1 = fopen(name_1, "rb");
  if (file_1 == NULL) {
    printf("error opening %s\n", name_1);
    exit(1);
  }
  file_2 = fopen(name_2, "wb");
  if (file_2 == NULL) {
    printf("error opening %s\n", name_2);
    exit(1);
  }
  printf("\nstripping last byte of %s\n", argv[1]);
  printf("to %s\n", argv[2]);
  data = fgetc(file_1);
  while (!(feof(file_1))) {
    buf = data;
    data = fgetc(file_1);
    if (!(feof(file_1)))
      fputc(buf, file_2);
  }
  printf("\n");
  fclose(file_2);
  fclose(file_1);
  char syscmd[80];
  printf("%s:\n", name_1);
  sprintf(syscmd, "tail -3 %s | hexdump -C", name_1);
  system(syscmd);
  printf("\n%s:\n", name_2);
  sprintf(syscmd, "tail -3 %s | hexdump -C", name_2);
  system(syscmd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11f5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1248 <main+0xb8>
mov    -0x28(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1283 <main+0xf3>
mov    -0x30(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d9 <main+0x149>
jmp    130e <main+0x17e>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
jne    1309 <main+0x179>
mov    -0x38(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
jmp    12bb <main+0x12b>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xd0d(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <system@plt>
mov    -0x30(%rbp),%rsi
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xcd8(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
mov    (%rsi),%rsi
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%ebx
jle    130a <main+0x16a>
mov    0x8(%r13),%r15
mov    0x10(%r13),%rbx
lea    0xe48(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1317 <main+0x177>
mov    %rax,%r14
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1323 <main+0x183>
mov    %rax,%r12
mov    %rbx,0x8(%rsp)
mov    0x8(%r13),%rsi
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r13),%rsi
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1090 <feof@plt>
jmp    125a <main+0xba>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1090 <feof@plt>
mov    %ebx,%ebp
test   %eax,%eax
jne    1280 <main+0xe0>
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1250 <main+0xb0>
mov    %ebp,%edi
mov    %r12,%rsi
call   1080 <fputc@plt>
jmp    1250 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xdd7(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdad(%rip),%r14
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <system@plt>
lea    0xda3(%rip),%rdi
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%rsi
lea    0xcf5(%rip),%rdi
jmp    132d <main+0x18d>
lea    0xd09(%rip),%rdi
mov    %r15,%rsi
jmp    132d <main+0x18d>
lea    0xcfd(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%s by DE\0A\00"
@.str.1 = [26 x i8] c"usage: %s infile outfile\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [18 x i8] c"error opening %s\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [28 x i8] c"\0Astripping last byte of %s\0A\00"
@.str.6 = [7 x i8] c"to %s\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [5 x i8] c"%s:\0A\00"
@.str.9 = [24 x i8] c"tail -3 %s | hexdump -C\00"
@.str.10 = [6 x i8] c"\0A%s:\0A\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 i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %11
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %8
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
store i8* %31, i8** %9
%32 = load i8*, i8** %8
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %6
%34 = load i32*, i32** %6
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %25
%37 = load i8*, i8** %8
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %25
%41 = load i8*, i8** %9
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %42, i32** %7
%43 = load i32*, i32** %7
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = load i8*, i8** %9
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %56)
%58 = load i32*, i32** %6
%59 = call i32 @fgetc(i32* %58)
store i32 %59, i32* %10
br label %60
60: ; preds = %76, %49
%61 = load i32*, i32** %6
%62 = call i32 @feof(i32* %61)
%63 = icmp ne i32 %62, 0
%64 = xor i1 %63, true
br i1 %64, label %65, label %77
65: ; preds = %60
%66 = load i32, i32* %10
store i32 %66, i32* %11
%67 = load i32*, i32** %6
%68 = call i32 @fgetc(i32* %67)
store i32 %68, i32* %10
%69 = load i32*, i32** %6
%70 = call i32 @feof(i32* %69)
%71 = icmp ne i32 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %65
%73 = load i32, i32* %11
%74 = load i32*, i32** %7
%75 = call i32 @fputc(i32 %73, i32* %74)
br label %76
76: ; preds = %72, %65
br label %60
77: ; preds = %60
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%79 = load i32*, i32** %7
%80 = call i32 @fclose(i32* %79)
%81 = load i32*, i32** %6
%82 = call i32 @fclose(i32* %81)
%83 = load i8*, i8** %8
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %83)
%85 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%86 = load i8*, i8** %8
%87 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %86)
%88 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%89 = call i32 @system(i8* %88)
%90 = load i8*, i8** %9
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %90)
%92 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%93 = load i8*, i8** %9
%94 = call i32 @sprintf(i8* %92, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %93)
%95 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%96 = call i32 @system(i8* %95)
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s by DE\0A\00"
@.str.1 = [26 x i8] c"usage: %s infile outfile\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [18 x i8] c"error opening %s\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [28 x i8] c"\0Astripping last byte of %s\0A\00"
@.str.6 = [7 x i8] c"to %s\0A\00"
@.str.8 = [5 x i8] c"%s:\0A\00"
@.str.9 = [24 x i8] c"tail -3 %s | hexdump -C\00"
@.str.10 = [6 x i8] c"\0A%s:\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = load i8*, i8** %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %11
%22 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %21
%28 = load i8*, i8** %12
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %14
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %30)
%32 = tail call i32 @fgetc(i32* %16)
%33 = tail call i32 @feof(i32* %16)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %27, %42
%36 = phi i32 [ %37, %42 ], [ %32, %27 ]
%37 = tail call i32 @fgetc(i32* %16)
%38 = tail call i32 @feof(i32* %16)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @fputc(i32 %36, i32* %22)
br label %42
42: ; preds = %40, %35
%43 = tail call i32 @feof(i32* %16)
%44 = icmp eq i32 %43, 0
br i1 %44, label %35, label %45
45: ; preds = %42, %27
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @fclose(i32* %22)
%48 = tail call i32 @fclose(i32* %16)
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %13)
%51 = call i32 @sprintf(i8* %49, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %13)
%52 = call i32 @system(i8* %49)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %15)
%54 = call i32 @sprintf(i8* %49, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %15)
%55 = call i32 @system(i8* %49)
ret i32 0
}