#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*/ time_t;
struct tm {
  int dummy;
};
struct lconv {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ LC_ALL;
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
scalar_t__ isprint(int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  time_t start_time;
  time_t end_time;
  struct tm *timeinfo;
  char buffer[80];
  double duration_secs;
  struct lconv *lc;
  if (argc == 3) {
    printf("Locale: %s\n", setlocale(LC_ALL, NULL));
    time(&start_time);
    timeinfo = localtime(&start_time);
    strftime(buffer, 80, "%c", timeinfo);
    printf("Date is: %s\n", buffer);
    char *source_file = argv[1];
    FILE *fin = fopen(source_file, "rb");
    if (NULL == fin) {
      printf("Null input file pointer from path: %s.\n", source_file);
      return 1;
    }
    char *destination_file = argv[2];
    FILE *fout = fopen(destination_file, "w");
    if (NULL == fout) {
      printf("Null output file pointer from path: %s.\n", destination_file);
      return 1;
    }
    int c;
    while ((c = fgetc(fin)) != EOF) {
      if (isprint(c) || c == '\n') {
        fputc(c, fout);
      }
    }
    fclose(fin);
    fclose(fout);
    time(&end_time);
    timeinfo = localtime(&end_time);
    strftime(buffer, 80, "%c", timeinfo);
    printf("Date is: %s\n", buffer);
    duration_secs = difftime(end_time, start_time);
    printf("Duration/sec: %.f\n", duration_secs);
    printf("Locale: %s\n", setlocale(LC_ALL, ""));
    return 0;
  } else {
    printf("Use: ./clean_to_ascii [source-filename] [destination_filename]");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    13f6 <main+0x246>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <setlocale@plt>
mov    %rax,%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1090 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x50,%esi
lea    0xdec(%rip),%rdx
call   10c0 <strftime@plt>
lea    -0x70(%rbp),%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x90(%rbp)
xor    %eax,%eax
cmp    -0x90(%rbp),%rax
jne    1290 <main+0xe0>
mov    -0x88(%rbp),%rsi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140b <main+0x25b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
xor    %eax,%eax
cmp    -0xa0(%rbp),%rax
jne    12e9 <main+0x139>
mov    -0x98(%rbp),%rsi
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140b <main+0x25b>
jmp    12ee <main+0x13e>
mov    -0x90(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0xa4(%rbp)
mov    0x2ce1(%rip),%rcx
cmp    (%rcx),%eax
je     1348 <main+0x198>
mov    -0xa4(%rbp),%edi
call   10b0 <isprint@plt>
cmp    $0x0,%rax
jne    1331 <main+0x181>
cmpl   $0xa,-0xa4(%rbp)
jne    1343 <main+0x193>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rsi
call   1080 <fputc@plt>
jmp    12ee <main+0x13e>
mov    -0x90(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x18(%rbp),%rdi
call   1090 <time@plt>
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x50,%esi
lea    0xc82(%rip),%rdx
call   10c0 <strftime@plt>
lea    -0x70(%rbp),%rsi
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <difftime@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
lea    0xcb5(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
lea    0xc72(%rip),%rsi
call   10a0 <setlocale@plt>
mov    %rax,%rsi
lea    0xc1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    140b <main+0x25b>
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
cmp    $0x3,%edi
jne    1314 <main+0x164>
mov    %rsi,%r14
mov    0x2e09(%rip),%r15
mov    (%r15),%edi
xor    %esi,%esi
call   10a0 <setlocale@plt>
lea    0xe20(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe06(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %rax,%rcx
call   10c0 <strftime@plt>
lea    0xded(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r14),%rbp
lea    0xde5(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1324 <main+0x174>
mov    %rax,%rbx
mov    0x10(%r14),%rbp
lea    0xdf1(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     132d <main+0x17d>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    0x2d6f(%rip),%r12
cmp    (%r12),%eax
jne    1352 <main+0x1a2>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xd5d(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rax,%rcx
call   10c0 <strftime@plt>
lea    0xd44(%rip),%rdi
xor    %ebx,%ebx
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1060 <difftime@plt>
lea    0xd87(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    (%r15),%edi
lea    0xd4a(%rip),%rsi
call   10a0 <setlocale@plt>
lea    0xcf8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1343 <main+0x193>
lea    0xd6a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    133e <main+0x18e>
lea    0xcf4(%rip),%rdi
jmp    1334 <main+0x184>
lea    0xd15(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
jmp    137e <main+0x1ce>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     1283 <main+0xd3>
mov    %ebp,%edi
call   10b0 <isprint@plt>
cmp    $0xa,%ebp
je     1360 <main+0x1b0>
test   %rax,%rax
je     136a <main+0x1ba>
jmp    1360 <main+0x1b0>

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.lconv = type { i32 }
@.str = [12 x i8] c"Locale: %s\0A\00"
@LC_ALL = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [13 x i8] c"Date is: %s\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [40 x i8] c"Null input file pointer from path: %s.\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [41 x i8] c"Null output file pointer from path: %s.\0A\00"
@EOF = global i32 0
@.str.7 = [19 x i8] c"Duration/sec: %.f\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [63 x i8] c"Use: ./clean_to_ascii [source-filename] [destination_filename]\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 %struct.tm*
%9 = alloca [80 x i8]
%10 = alloca double
%11 = alloca %struct.lconv*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %89
19: ; preds = %2
%20 = load i32, i32* @LC_ALL
%21 = call i8* @setlocale(i32 %20, i8* null)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @time(i32* %6)
%24 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %24, %struct.tm** %8
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%26 = load %struct.tm*, %struct.tm** %8
%27 = call i32 @strftime(i8* %25, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %26)
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
store i8* %32, i8** %12
%33 = load i8*, i8** %12
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %34, i32** %13
%35 = load i32*, i32** %13
%36 = icmp eq i32* null, %35
br i1 %36, label %37, label %40
37: ; preds = %19
%38 = load i8*, i8** %12
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %38)
store i32 1, i32* %3
br label %91
40: ; preds = %19
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
store i8* %43, i8** %14
%44 = load i8*, i8** %14
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %45, i32** %15
%46 = load i32*, i32** %15
%47 = icmp eq i32* null, %46
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = load i8*, i8** %14
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %49)
store i32 1, i32* %3
br label %91
51: ; preds = %40
br label %52
52: ; preds = %68, %51
%53 = load i32*, i32** %13
%54 = call i32 @fgetc(i32* %53)
store i32 %54, i32* %16
%55 = load i32, i32* @EOF
%56 = icmp ne i32 %54, %55
br i1 %56, label %57, label %69
57: ; preds = %52
%58 = load i32, i32* %16
%59 = call i64 @isprint(i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %57
%62 = load i32, i32* %16
%63 = icmp eq i32 %62, 10
br i1 %63, label %64, label %68
64: ; preds = %61, %57
%65 = load i32, i32* %16
%66 = load i32*, i32** %15
%67 = call i32 @fputc(i32 %65, i32* %66)
br label %68
68: ; preds = %64, %61
br label %52
69: ; preds = %52
%70 = load i32*, i32** %13
%71 = call i32 @fclose(i32* %70)
%72 = load i32*, i32** %15
%73 = call i32 @fclose(i32* %72)
%74 = call i32 @time(i32* %7)
%75 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %75, %struct.tm** %8
%76 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%77 = load %struct.tm*, %struct.tm** %8
%78 = call i32 @strftime(i8* %76, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %77)
%79 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %79)
%81 = load i32, i32* %7
%82 = load i32, i32* %6
%83 = call double @difftime(i32 %81, i32 %82)
store double %83, double* %10
%84 = load double, double* %10
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %84)
%86 = load i32, i32* @LC_ALL
%87 = call i8* @setlocale(i32 %86, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0))
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %87)
store i32 0, i32* %3
br label %91
89: ; preds = %2
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %91
91: ; preds = %89, %69, %48, %37
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
%struct.lconv = type { i32 }
%struct.tm = type { i32 }
@.str = [12 x i8] c"Locale: %s\0A\00"
@LC_ALL = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [13 x i8] c"Date is: %s\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [40 x i8] c"Null input file pointer from path: %s.\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [41 x i8] c"Null output file pointer from path: %s.\0A\00"
@EOF = global i32 0
@.str.7 = [19 x i8] c"Duration/sec: %.f\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [63 x i8] c"Use: ./clean_to_ascii [source-filename] [destination_filename]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 3
br i1 %9, label %10, label %61
10: ; preds = %2
%11 = load i32, i32* @LC_ALL
%12 = tail call i8* @setlocale(i32 %11, i8* null)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @time(i32* %3)
%15 = call %struct.tm* @localtime(i32* %3)
%16 = call i32 @strftime(i8* %8, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = 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 %22, label %24
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %63
24: ; preds = %10
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %33, label %29
29: ; preds = %24
%30 = call i32 @fgetc(i32* %20)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %47, label %35
33: ; preds = %24
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %26)
br label %63
35: ; preds = %29, %43
%36 = phi i32 [ %44, %43 ], [ %30, %29 ]
%37 = call i64 @isprint(i32 %36)
%38 = icmp ne i64 %37, 0
%39 = icmp eq i32 %36, 10
%40 = or i1 %39, %38
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @fputc(i32 %36, i32* %27)
br label %43
43: ; preds = %35, %41
%44 = call i32 @fgetc(i32* %20)
%45 = load i32, i32* @EOF
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %35
47: ; preds = %43, %29
%48 = call i32 @fclose(i32* %20)
%49 = call i32 @fclose(i32* %27)
%50 = call i32 @time(i32* %4)
%51 = call %struct.tm* @localtime(i32* %4)
%52 = call i32 @strftime(i8* %8, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %51)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%54 = load i32, i32* %4
%55 = load i32, i32* %3
%56 = call double @difftime(i32 %54, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %56)
%58 = load i32, i32* @LC_ALL
%59 = call i8* @setlocale(i32 %58, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0))
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %59)
br label %63
61: ; preds = %2
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0))
br label %63
63: ; preds = %22, %47, %33, %61
%64 = phi i32 [ 1, %61 ], [ 1, %22 ], [ 1, %33 ], [ 0, %47 ]
ret i32 %64
}