#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ wf(char *, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int i;
  for (i = 1; i < argc; ++i) {
    FILE *fp = fopen(argv[i], "r");
    if (fp == NULL) {
      fprintf(stderr, "%s: can't open '%s' (%s)\n", argv[0], argv[i],
              strerror(errno));
      return EXIT_FAILURE;
    } else {
      wf(argv[i], fp);
      fclose(fp);
    }
  }
  if (argc == 1)
    wf(NULL, stdin);
  return EXIT_SUCCESS;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1231 <main+0xe1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe74(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1200 <main+0xb0>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
lea    0xe18(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125a <main+0x10a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <wf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1223 <main+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x1d>
cmpl   $0x1,-0x8(%rbp)
jne    124e <main+0xfe>
mov    0x2da6(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
cmp    $0x2,%edi
jl     11b1 <main+0x61>
mov    %rsi,%r12
mov    %r14d,%r13d
mov    $0x1,%ebx
lea    0xe8b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d1 <main+0x81>
mov    %rax,%rbp
mov    (%r12,%rbx,8),%rdi
mov    %rax,%rsi
call   1050 <wf@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1180 <main+0x30>
mov    0x2e08(%rip),%rbx
cmp    $0x1,%r14d
jne    120e <main+0xbe>
mov    0x2e23(%rip),%rax
mov    (%rax),%rsi
xor    %edi,%edi
call   1050 <wf@plt>
jmp    120e <main+0xbe>
mov    0x2e00(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%r14
mov    (%r12,%rbx,8),%rbx
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe0b(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    0x2dba(%rip),%rbx
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"%s: can't open '%s' (%s)\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@stdin = global i32* null
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %8
8: ; preds = %46, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %49
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %7
%19 = load i32*, i32** %7
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %35
21: ; preds = %12
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %30, i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %57
35: ; preds = %12
%36 = load i8**, i8*** %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = load i32*, i32** %7
%42 = call i32 @wf(i8* %40, i32* %41)
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %35
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %8
49: ; preds = %8
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32*, i32** @stdin
%54 = call i32 @wf(i8* null, i32* %53)
br label %55
55: ; preds = %52, %49
%56 = load i32, i32* @EXIT_SUCCESS
store i32 %56, i32* %3
br label %57
57: ; preds = %55, %21
%58 = load i32, i32* %3
ret i32 %58
}

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