#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 errno;
int /*<<< orphan*/ filecpy(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc == 1) {
    errno = 1;
    char *str = "chenzongzhi";
    perror(str);
    fprintf(stderr, "There is only one input %s\n", argv[0]);
    filecpy(stdin, stdout);
  } else {
    fp = fopen(argv[1], "r");
    filecpy(fp, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ba <main+0x7a>
mov    0x2e69(%rip),%rax
movl   $0x1,(%rax)
lea    0xe8c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <perror@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
jmp    11e4 <main+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
je     116e <main+0x2e>
mov    0x8(%rbx),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1030 <filecpy@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e5b(%rip),%rax
movl   $0x1,(%rax)
lea    0xe7e(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe72(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%rdi
jmp    115c <main+0x1c>

LLVM IR (-O0):
@errno = global i32 0
@.str = [12 x i8] c"chenzongzhi\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"There is only one input %s\0A\00"
@stdin = global i32* null
@stdout = global i32 0
@.str.2 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %21
10: ; preds = %2
store i32 1, i32* @errno
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %7
%11 = load i8*, i8** %7
%12 = call i32 @perror(i8* %11)
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** @stdin
%19 = load i32, i32* @stdout
%20 = call i32 @filecpy(i32* %18, i32 %19)
br label %29
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = load i32, i32* @stdout
%28 = call i32 @filecpy(i32* %26, i32 %27)
br label %29
29: ; preds = %21, %10
ret i32 0
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [12 x i8] c"chenzongzhi\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"There is only one input %s\0A\00"
@stdin = global i32* null
@stdout = global i32 0
@.str.2 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
store i32 1, i32* @errno
%5 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = load i32*, i32** @stdin
br label %14
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.2, i64 0, i64 0))
br label %14
14: ; preds = %10, %4
%15 = phi i32* [ %13, %10 ], [ %9, %4 ]
%16 = load i32, i32* @stdout
%17 = tail call i32 @filecpy(i32* %15, i32 %16)
ret i32 0
}