#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
void openbinpos_() {
  char magic[10];
  if (fread(magic, 1, 4, stdin) != 4) {
    fprintf(stderr, "Couldn't read magic number from BINPOS\n");
    exit(-1);
  }
  magic[4] = '\0';
  if (strcmp(magic, "fxyz") != 0) {
    fprintf(stderr, "bad magic number \"%s\"\n", magic);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<openbinpos_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
mov    0x2e95(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x4,%eax
je     118e <openbinpos_+0x4e>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movb   $0x0,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11d1 <openbinpos_+0x91>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    -0xa(%rbp),%rdx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openbinpos_>:
sub    $0x18,%rsp
mov    0x2e9d(%rip),%rax
mov    (%rax),%ecx
lea    0xe(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cmp    $0x4,%eax
jne    1186 <openbinpos_+0x46>
movb   $0x0,0x12(%rsp)
lea    0xeb6(%rip),%rsi
lea    0xe(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11a7 <openbinpos_+0x67>
add    $0x18,%rsp
ret
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
lea    0xe(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [40 x i8] c"Couldn't read magic number from BINPOS\0A\00"
@.str.1 = [5 x i8] c"fxyz\00"
@.str.2 = [23 x i8] c"bad magic number \22%s\22\0A\00"
define void @openbinpos_() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fread(i8* %2, i32 1, i32 4, i32 %3)
%5 = icmp ne i32 %4, 4
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
store i8 0, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %10
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [40 x i8] c"Couldn't read magic number from BINPOS\0A\00"
@.str.1 = [5 x i8] c"fxyz\00"
@.str.2 = [23 x i8] c"bad magic number \22%s\22\0A\00"
define void @openbinpos_() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fread(i8* %2, i32 1, i32 4, i32 %3)
%5 = icmp eq i32 %4, 4
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
store i8 0, i8* %11
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %10
ret void
}