#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileprint(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc == 1) {
    fileprint(stdin, "stdin");
    exit(EXIT_SUCCESS);
  }
  while (--argc > 0) {
    if ((fp = fopen(*++argv, "r")) == NULL) {
      fprintf(stderr, "fprint: cannot open %s\n", *argv);
      exit(EXIT_FAILURE);
    }
    fileprint(fp, *argv);
    (void)fclose(fp);
  }
  exit(EXIT_SUCCESS);
}


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    1194 <main+0x44>
mov    0x2e71(%rip),%rax
mov    (%rax),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <fileprint@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1199 <main+0x49>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1220 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe41(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1202 <main+0xb2>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <fileprint@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1199 <main+0x49>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1174 <main+0x24>
mov    0x2e85(%rip),%rax
mov    (%rax),%rdi
lea    0xe93(%rip),%rsi
call   1050 <fileprint@plt>
jmp    11c4 <main+0x74>
jle    11c4 <main+0x74>
mov    %rsi,%rbx
mov    %edi,%r15d
add    $0x1,%r15d
add    $0x8,%rbx
lea    0xe7b(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d2 <main+0x82>
mov    %rax,%rbp
mov    (%rbx),%rsi
mov    %rax,%rdi
call   1050 <fileprint@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0xffffffff,%r15d
add    $0x8,%rbx
cmp    $0x2,%r15d
jg     1190 <main+0x40>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [6 x i8] c"stdin\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"fprint: cannot open %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32*, i32** @stdin
%11 = call i32 @fileprint(i32* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_SUCCESS
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %32
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %19
%33 = load i32*, i32** %6
%34 = load i8**, i8*** %5
%35 = load i8*, i8** %34
%36 = call i32 @fileprint(i32* %33, i8* %35)
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
br label %15
39: ; preds = %15
%40 = load i32, i32* @EXIT_SUCCESS
%41 = call i32 @exit(i32 %40)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [6 x i8] c"stdin\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"fprint: cannot open %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %11, label %30
6: ; preds = %2
%7 = load i32*, i32** @stdin
%8 = tail call i32 @fileprint(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %4, %24
%12 = phi i32 [ %25, %24 ], [ %0, %4 ]
%13 = phi i8** [ %14, %24 ], [ %1, %4 ]
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %11
%25 = add nsw i32 %12, -1
%26 = load i8*, i8** %14
%27 = tail call i32 @fileprint(i32* %16, i8* %26)
%28 = tail call i32 @fclose(i32* %16)
%29 = icmp sgt i32 %12, 2
br i1 %29, label %11, label %30
30: ; preds = %24, %4
%31 = load i32, i32* @EXIT_SUCCESS
%32 = tail call i32 @exit(i32 %31)
unreachable
}