#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*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
scalar_t__ lseek64(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int, char *, int);
int peek_map(int bitmap_fd, int block) {
  char c = 0;
  if (lseek64(bitmap_fd, block, SEEK_SET) < 0) {
    perror("peek_map lseek64");
    exit(-1);
  }
  if (read(bitmap_fd, &c, 1) < 0) {
    perror("peek_map read");
    exit(-1);
  }
  return c;
}


x86 assembly (clang, -O0):
<peek_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek64@plt>
cmp    $0x0,%rax
jge    1186 <peek_map+0x46>
lea    0xe89(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <read@plt>
cmp    $0x0,%rax
jge    11b7 <peek_map+0x77>
lea    0xe69(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peek_map>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movb   $0x0,0xf(%rsp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek64@plt>
test   %rax,%rax
js     1180 <peek_map+0x40>
lea    0xf(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <read@plt>
test   %rax,%rax
js     1189 <peek_map+0x49>
movsbl 0xf(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe79(%rip),%rdi
jmp    1190 <peek_map+0x50>
lea    0xe81(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [17 x i8] c"peek_map lseek64\00"
@.str.1 = [14 x i8] c"peek_map read\00"
define i32 @peek_map(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8 0, i8* %5
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = load i32, i32* @SEEK_SET
%9 = call i64 @lseek64(i32 %6, i32 %7, i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = load i32, i32* %3
%16 = call i64 @read(i32 %15, i8* %5, i32 1)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %14
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [17 x i8] c"peek_map lseek64\00"
@.str.1 = [14 x i8] c"peek_map read\00"
define i32 @peek_map(i32 %0, i32 %1) {
%3 = alloca i8
store i8 0, i8* %3
%4 = load i32, i32* @SEEK_SET
%5 = tail call i64 @lseek64(i32 %0, i32 %1, i32 %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = call i64 @read(i32 %0, i8* %3, i32 1)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %10
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
ret i32 %18
}