#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*/ IndentLine(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  FILE *F;
  char line[100000];
  char indstr[150000];
  if (argc < 2) {
    F = stdin;
  } else {
    if ((F = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "could not open %s\n", argv[1]);
    }
  }
  line[0] = '\0';
  indstr[0] = '\0';
  while (fgets(line, 100000, F)) {
    if (feof(F)) {
      return (0);
    }
    IndentLine(line, indstr);
    printf("%s", indstr);
    line[0] = '\0';
    indstr[0] = '\0';
  }
  fclose(F);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a6 <main+0x36>
mov    0x2e4e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11ea <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e5 <main+0x75>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe22(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11ea <main+0x7a>
movb   $0x0,-0x186c0(%rbp)
movb   $0x0,-0x3d0b0(%rbp)
lea    -0x186c0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x186a0,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     126f <main+0xff>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1236 <main+0xc6>
movl   $0x0,-0x4(%rbp)
jmp    127f <main+0x10f>
lea    -0x186c0(%rbp),%rdi
lea    -0x3d0b0(%rbp),%rsi
call   1050 <IndentLine@plt>
lea    -0x3d0b0(%rbp),%rsi
lea    0xdbe(%rip),%rdi
call   1040 <printf@plt>
movb   $0x0,-0x186c0(%rbp)
movb   $0x0,-0x3d0b0(%rbp)
jmp    11f8 <main+0x88>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3d0b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3d098,%rsp
cmp    $0x1,%edi
jg     118f <main+0x1f>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rbx
jmp    11c5 <main+0x55>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c5 <main+0x55>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe44(%rip),%rsi
call   1070 <fprintf@plt>
xor    %ebx,%ebx
movb   $0x0,(%rsp)
movb   $0x0,0x186a0(%rsp)
mov    %rsp,%rdi
mov    $0x186a0,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1244 <main+0xd4>
mov    %rsp,%r14
lea    0x186a0(%rsp),%r15
lea    0xe1d(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    124c <main+0xdc>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <IndentLine@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
movb   $0x0,(%rsp)
movb   $0x0,0x186a0(%rsp)
mov    %r14,%rdi
mov    $0x186a0,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1200 <main+0x90>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x3d098,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"could not open %s\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100000 x i8]
%4 = alloca [150000 x i8]
%5 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [150000 x i8], [150000 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i32*, i32** @stdin
br label %19
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %10, %15, %8
%20 = phi i32* [ %9, %8 ], [ null, %15 ], [ %13, %10 ]
store i8 0, i8* %5
store i8 0, i8* %6
%21 = call i64 @fgets(i8* %5, i32 100000, i32* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %19, %26
%24 = call i64 @feof(i32* %20)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = call i32 @IndentLine(i8* %5, i8* %6)
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
store i8 0, i8* %5
store i8 0, i8* %6
%29 = call i64 @fgets(i8* %5, i32 100000, i32* %20)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %23
31: ; preds = %26, %19
%32 = call i32 @fclose(i32* %20)
br label %33
33: ; preds = %23, %31
ret i32 0
}