#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int scanf(char *, char *);
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char input[80];
  FILE *out_file;
  if (argv[1] && strcmp(argv[1], "-") != 0) {
    out_file = fopen(argv[1], "w");
  } else {
    out_file = NULL;
  }
  while (scanf("%s\n", input) == 1) {
    if (out_file) {
      fprintf(out_file, "%s\n", input);
      fprintf(stdout, "%s\n", input);
    } else {
      fprintf(stdout, "%s\n", input);
    }
  }
  if (out_file) {
    fclose(out_file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11b0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x68(%rbp)
jmp    11b8 <main+0x68>
movq   $0x0,-0x68(%rbp)
jmp    11bd <main+0x6d>
lea    -0x60(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1233 <main+0xe3>
cmpq   $0x0,-0x68(%rbp)
je     1214 <main+0xc4>
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe14(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdfa(%rip),%rsi
call   1050 <fprintf@plt>
jmp    122e <main+0xde>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rdx
lea    0xddb(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11bd <main+0x6d>
cmpq   $0x0,-0x68(%rbp)
je     1247 <main+0xf7>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     118d <main+0x3d>
mov    %rsi,%rbx
lea    0xe92(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     118d <main+0x3d>
mov    0x8(%rbx),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
jmp    1190 <main+0x40>
xor    %r14d,%r14d
lea    0xe6d(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11f4 <main+0xa4>
mov    0x2e35(%rip),%r12
lea    0xe52(%rip),%r15
mov    %rsp,%rbx
jmp    11df <main+0x8f>
nopw   0x0(%rax,%rax,1)
mov    (%r12),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11f4 <main+0xa4>
test   %r14,%r14
je     11c0 <main+0x70>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
jmp    11c0 <main+0x70>
test   %r14,%r14
je     1201 <main+0xb1>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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