#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 *);
int write(int, char *, int);
void poke_map(int bitmap_fd, int block, char val) {
  if (lseek64(bitmap_fd, block, SEEK_SET) < 0) {
    perror("poke_map lseek64");
    exit(-1);
  }
  if (write(bitmap_fd, &val, 1) != 1) {
    perror("poke_map write");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<poke_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek64@plt>
cmp    $0x0,%rax
jge    1187 <poke_map+0x47>
lea    0xe88(%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 <write@plt>
cmp    $0x1,%eax
je     11b7 <poke_map+0x77>
lea    0xe69(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poke_map>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %dl,0xf(%rsp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek64@plt>
test   %rax,%rax
js     117a <poke_map+0x3a>
lea    0xf(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    1183 <poke_map+0x43>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe7f(%rip),%rdi
jmp    118a <poke_map+0x4a>
lea    0xe87(%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"poke_map lseek64\00"
@.str.1 = [15 x i8] c"poke_map write\00"
define void @poke_map(i32 %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = load i32, i32* @SEEK_SET
%10 = call i64 @lseek64(i32 %7, i32 %8, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %3
%16 = load i32, i32* %4
%17 = call i32 @write(i32 %16, i8* %6, i32 1)
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %15
ret void
}

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