#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 2)
    return 1;
  FILE *file = fopen(argv[1], "r");
  if (file != NULL) {
    char line[256];
    char lineWithChanges[258];
    while (fgets(line, sizeof line, file) != NULL) {
      if (strlen(line) == 1)
        memcpy(lineWithChanges, " .\n\0", 4);
      else {
        lineWithChanges[0] = ' ';
        lineWithChanges[1] = ' ';
        memcpy(lineWithChanges + 2, line, sizeof line);
      }
      fputs(lineWithChanges, stdout);
    }
    fclose(file);
  } else {
    perror(argv[1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    127e <main+0x10e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     126a <main+0xfa>
jmp    11c7 <main+0x57>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     125c <main+0xec>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1218 <main+0xa8>
lea    -0x230(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
jmp    1242 <main+0xd2>
movb   $0x20,-0x230(%rbp)
movb   $0x20,-0x22f(%rbp)
lea    -0x230(%rbp),%rdi
add    $0x2,%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1070 <memcpy@plt>
lea    -0x230(%rbp),%rdi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
jmp    11c7 <main+0x57>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1277 <main+0x107>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <perror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    $0x1,%eax
cmp    $0x2,%edi
jne    124a <main+0xda>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125c <main+0xec>
mov    %rax,%r15
lea    0x110(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1240 <main+0xd0>
lea    0x2(%rsp),%r14
lea    0x110(%rsp),%rbx
lea    0xe26(%rip),%r12
mov    %rsp,%r13
mov    0x2dfa(%rip),%rbp
jmp    1226 <main+0xb6>
nopl   0x0(%rax,%rax,1)
movw   $0x2020,(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1070 <memcpy@plt>
mov    0x0(%rbp),%esi
mov    %r13,%rdi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1240 <main+0xd0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    11f0 <main+0x80>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
jmp    1201 <main+0x91>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdi
call   1090 <perror@plt>
jmp    1248 <main+0xd8>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c" .\0A\00\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca [258 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %52
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %46
19: ; preds = %12
br label %20
20: ; preds = %39, %19
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%22 = load i32*, i32** %6
%23 = call i32* @fgets(i8* %21, i32 256, i32* %22)
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %43
25: ; preds = %20
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 0
%31 = call i32 @memcpy(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %39
32: ; preds = %25
%33 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 0
store i8 32, i8* %33
%34 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 1
store i8 32, i8* %34
%35 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%38 = call i32 @memcpy(i8* %36, i8* %37, i32 256)
br label %39
39: ; preds = %32, %29
%40 = getelementptr inbounds [258 x i8], [258 x i8]* %8, i64 0, i64 0
%41 = load i32, i32* @stdout
%42 = call i32 @fputs(i8* %40, i32 %41)
br label %20
43: ; preds = %20
%44 = load i32*, i32** %6
%45 = call i32 @fclose(i32* %44)
br label %51
46: ; preds = %12
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @perror(i8* %49)
br label %51
51: ; preds = %46, %43
store i32 0, i32* %3
br label %52
52: ; preds = %51, %11
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c" .\0A\00\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [258 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %36
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %33, label %11
11: ; preds = %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [258 x i8], [258 x i8]* %4, i64 0, i64 0
%14 = call i32* @fgets(i8* %12, i32 256, i32* %9)
%15 = icmp eq i32* %14, null
br i1 %15, label %31, label %16
16: ; preds = %11
%17 = getelementptr inbounds [258 x i8], [258 x i8]* %4, i64 0, i64 1
%18 = getelementptr inbounds [258 x i8], [258 x i8]* %4, i64 0, i64 2
br label %19
19: ; preds = %16, %26
%20 = call i32 @strlen(i8* %12)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @memcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %26
24: ; preds = %19
store i8 32, i8* %13
store i8 32, i8* %17
%25 = call i32 @memcpy(i8* %18, i8* %12, i32 256)
br label %26
26: ; preds = %24, %22
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* %13, i32 %27)
%29 = call i32* @fgets(i8* %12, i32 256, i32* %9)
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %19
31: ; preds = %26, %11
%32 = call i32 @fclose(i32* %9)
br label %36
33: ; preds = %6
%34 = load i8*, i8** %7
%35 = tail call i32 @perror(i8* %34)
br label %36
36: ; preds = %31, %33, %2
%37 = phi i32 [ 1, %2 ], [ 0, %33 ], [ 0, %31 ]
ret i32 %37
}