#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*/ brev(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int nb, char **cmde) {
  int i;
  if (nb == 1)
    brev(stdin, NULL);
  else
    for (i = 1; i < nb; i++) {
      FILE *f = fopen(cmde[i], "r");
      if (f != NULL) {
        brev(f, NULL);
        fclose(f);
      } else {
        fprintf(stderr, "could not open %s for reading\n", cmde[i]);
      }
    }
  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    1178 <main+0x38>
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <brev@plt>
jmp    1206 <main+0xc6>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <main+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe62(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11cd <main+0x8d>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <brev@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ee <main+0xae>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe19(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11f3 <main+0xb3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x3f>
jmp    1206 <main+0xc6>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1163 <main+0x23>
mov    0x2e91(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
call   1040 <brev@plt>
jmp    11c6 <main+0x86>
jle    11c6 <main+0x86>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe89(%rip),%r14
lea    0xe84(%rip),%r15
jmp    119e <main+0x5e>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%rbp,8),%rdx
mov    %r15,%rsi
call   1050 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11c6 <main+0x86>
mov    (%r12,%rbp,8),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <brev@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1195 <main+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"could not open %s for reading\0A\00"
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
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32*, i32** @stdin
%12 = call i32 @brev(i32* %11, i32* null)
br label %45
13: ; preds = %2
store i32 1, i32* %6
br label %14
14: ; preds = %41, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %44
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** %7
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %32
27: ; preds = %18
%28 = load i32*, i32** %7
%29 = call i32 @brev(i32* %28, i32* null)
%30 = load i32*, i32** %7
%31 = call i32 @fclose(i32* %30)
br label %40
32: ; preds = %18
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %32, %27
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %14
44: ; preds = %14
br label %45
45: ; preds = %44, %10
ret i32 0
}

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