#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*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int strlen(char *);
int main(void) {
  char line[128];
  int len;
  FILE *in, *out;
  in = fopen("input.dat", "r");
  out = fopen("output.dat", "w");
  assert(in);
  assert(out);
  while (fgets(line, sizeof(line), in) != NULL) {
    if (line[0] == '\n') {
      fprintf(out, "==================================================\n");
      fprintf(out, "this is a white line\n");
      len = strlen(line);
      fprintf(out, "the length of this line is %d\n", len);
      fprintf(out, "char is '%c'\n", line[0]);
      fprintf(out, "==================================================\n\n");
    }
    len = strlen(line);
    fprintf(out, "==================================================\n");
    fprintf(out, "the line you've just entered is '%s'\n", line);
    fprintf(out, "the length of it is %d\n", strlen(line));
    fprintf(out, "first two chars '%c' and '%c'\n", line[0], line[1]);
    fprintf(out, "last two chars '%c' and '%c'\n", line[len - 2],
            line[len - 1]);
    fprintf(out, "==================================================\n\n");
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xa0(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <assert@plt>
mov    -0xa8(%rbp),%rdi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1364 <main+0x204>
movsbl -0x90(%rbp),%eax
cmp    $0xa,%eax
jne    1278 <main+0x118>
mov    -0xa8(%rbp),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0x94(%rbp),%edx
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
movsbl -0x90(%rbp),%edx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
mov    -0xa8(%rbp),%rdi
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%edx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
movsbl -0x90(%rbp),%edx
movsbl -0x8f(%rbp),%ecx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x94(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%edx
ff
mov    -0x94(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%ecx
ff
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    11be <main+0x5e>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe78(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe6e(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1060 <assert@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1329 <main+0x1b9>
lea    0xe39(%rip),%r12
lea    0xea9(%rip),%rbp
jmp    12a7 <main+0x137>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    $0x33,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
lea    0xeab(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
lea    0xeb5(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
movsbl (%rsp),%edx
movsbl 0x1(%rsp),%ecx
mov    %rbx,%rdi
lea    0xeb1(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
movslq %r13d,%rax
movsbl -0x2(%rax,%r15,1),%edx
movsbl -0x1(%rax,%r15,1),%ecx
mov    %rbx,%rdi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x34,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1329 <main+0x1b9>
cmpb   $0xa,(%rsp)
jne    11f0 <main+0x80>
mov    $0x33,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    $0x15,%esi
mov    $0x1,%edx
lea    0xd76(%rip),%rdi
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
lea    0xd72(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
movsbl (%rsp),%edx
mov    %rbx,%rdi
lea    0xd7a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x34,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1090 <fwrite@plt>
jmp    11f0 <main+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [52 x i8] c"==================================================\0A\00"
@.str.5 = [22 x i8] c"this is a white line\0A\00"
@.str.6 = [31 x i8] c"the length of this line is %d\0A\00"
@.str.7 = [14 x i8] c"char is '%c'\0A\00"
@.str.8 = [53 x i8] c"==================================================\0A\0A\00"
@.str.9 = [38 x i8] c"the line you've just entered is '%s'\0A\00"
@.str.10 = [24 x i8] c"the length of it is %d\0A\00"
@.str.11 = [31 x i8] c"first two chars '%c' and '%c'\0A\00"
@.str.12 = [30 x i8] c"last two chars '%c' and '%c'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %4
%9 = call i32 @assert(i32* %8)
%10 = load i32*, i32** %5
%11 = call i32 @assert(i32* %10)
br label %12
12: ; preds = %39, %0
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i32* @fgets(i8* %13, i32 128, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %75
17: ; preds = %12
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %39
22: ; preds = %17
%23 = load i32*, i32** %5
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32*, i32** %5
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %3
%29 = load i32*, i32** %5
%30 = load i32, i32* %3
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %5
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %5
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
br label %39
39: ; preds = %22, %17
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
store i32 %41, i32* %3
%42 = load i32*, i32** %5
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32*, i32** %5
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = load i32*, i32** %5
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %49)
%51 = load i32*, i32** %5
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 1
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32 %54, i32 %57)
%59 = load i32*, i32** %5
%60 = load i32, i32* %3
%61 = sub nsw i32 %60, 2
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = load i32, i32* %3
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %65, i32 %71)
%73 = load i32*, i32** %5
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
br label %12
75: ; preds = %12
%76 = load i32*, i32** %4
%77 = call i32 @fclose(i32* %76)
%78 = load i32*, i32** %5
%79 = call i32 @fclose(i32* %78)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [52 x i8] c"==================================================\0A\00"
@.str.5 = [22 x i8] c"this is a white line\0A\00"
@.str.6 = [31 x i8] c"the length of this line is %d\0A\00"
@.str.7 = [14 x i8] c"char is '%c'\0A\00"
@.str.8 = [53 x i8] c"==================================================\0A\0A\00"
@.str.9 = [38 x i8] c"the line you've just entered is '%s'\0A\00"
@.str.10 = [24 x i8] c"the length of it is %d\0A\00"
@.str.11 = [31 x i8] c"first two chars '%c' and '%c'\0A\00"
@.str.12 = [30 x i8] c"last two chars '%c' and '%c'\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @assert(i32* %3)
%6 = tail call i32 @assert(i32* %4)
%7 = call i32* @fgets(i8* %2, i32 128, i32* %3)
%8 = icmp eq i32* %7, null
br i1 %8, label %48, label %9
9: ; preds = %0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
br label %11
11: ; preds = %9, %23
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i64 @fwrite(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i64 51, i64 1, i32* %4)
%16 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i64 21, i64 1, i32* %4)
%17 = call i32 @strlen(i8* %2)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %20)
%22 = call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i64 52, i64 1, i32* %4)
br label %23
23: ; preds = %14, %11
%24 = call i32 @strlen(i8* %2)
%25 = call i64 @fwrite(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i64 51, i64 1, i32* %4)
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%27 = call i32 @strlen(i8* %2)
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %27)
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = load i8, i8* %10
%32 = sext i8 %31 to i32
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32 %30, i32 %32)
%34 = add nsw i32 %24, -2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = add nsw i32 %24, -1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %38, i32 %43)
%45 = call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0), i64 52, i64 1, i32* %4)
%46 = call i32* @fgets(i8* %2, i32 128, i32* %3)
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %11
48: ; preds = %23, %0
%49 = call i32 @fclose(i32* %3)
%50 = call i32 @fclose(i32* %4)
ret i32 0
}