#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*/ FSETLOCKING_BYCALLER;
int /*<<< orphan*/ __fsetlocking(int /*<<< orphan*/ *, int /*<<< orphan*/);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
FILE *openForSeqRead(char *filename) {
  FILE *inFile;
  if (strcmp(filename, "stdin") == 0 || strcmp(filename, "-") == 0) {
    fprintf(stderr, "Reading queries from stdin.\n");
    inFile = stdin;
  } else
    inFile = fopen(filename, "r");
  if (inFile == NULL) {
    fprintf(stderr, "Failure to open input file: %s.  Error number:%d\n",
            filename, errno);
    exit(1);
  }
  __fsetlocking(inFile, FSETLOCKING_BYCALLER);
  return inFile;
}


x86 assembly (clang, -O0):
<openForSeqRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1190 <openForSeqRead+0x40>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <openForSeqRead+0x6a>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    11ce <openForSeqRead+0x7e>
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1207 <openForSeqRead+0xb7>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    0x2de3(%rip),%rax
mov    (%rax),%ecx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
call   1050 <__fsetlocking@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openForSeqRead>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1190 <openForSeqRead+0x40>
lea    0xe97(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1190 <openForSeqRead+0x40>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
jmp    11b1 <openForSeqRead+0x61>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     11d2 <openForSeqRead+0x82>
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <__fsetlocking@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2dee(%rip),%rax
mov    (%rax),%ecx
lea    0xe3c(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"Reading queries from stdin.\0A\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [50 x i8] c"Failure to open input file: %s. Error number:%d\0A\00"
@errno = global i32 0
@FSETLOCKING_BYCALLER = global i32 0
define i32* @openForSeqRead(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7, %1
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32*, i32** @stdin
store i32* %14, i32** %3
br label %18
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %17, i32** %3
br label %18
18: ; preds = %15, %11
%19 = load i32*, i32** %3
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %2
%24 = load i32, i32* @errno
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %18
%28 = load i32*, i32** %3
%29 = load i32, i32* @FSETLOCKING_BYCALLER
%30 = call i32 @__fsetlocking(i32* %28, i32 %29)
%31 = load i32*, i32** %3
ret i32* %31
}

LLVM IR (-O2):
@.str = [6 x i8] c"stdin\00"
@.str.1 = [2 x i8] c"-\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"Reading queries from stdin.\0A\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [50 x i8] c"Failure to open input file: %s. Error number:%d\0A\00"
@errno = global i32 0
@FSETLOCKING_BYCALLER = global i32 0
define i32* @openForSeqRead(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4, %1
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32*, i32** @stdin
br label %13
11: ; preds = %4
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = phi i32* [ %10, %7 ], [ %12, %11 ]
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %13
%22 = load i32, i32* @FSETLOCKING_BYCALLER
%23 = tail call i32 @__fsetlocking(i32* %14, i32 %22)
ret i32* %14
}