#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*/ errno;
int /*<<< orphan*/ exit(int);
unsigned long lseek(int, unsigned long, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_msg(char *, char *, int, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int write(int, char *, int);
void touch_file_page(int fd, unsigned long off, char c) {
  if (lseek(fd, off, SEEK_SET) != off) {
    test_msg("ERR: %s:%d: "
             "Lseek fail"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unlink_mmap01.c",
             27, errno, strerror(errno));
    exit(1);
  }
  if (write(fd, &c, 1) != 1) {
    test_msg("ERR: %s:%d: "
             "Write fail"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unlink_mmap01.c",
             32, errno, strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<touch_file_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e66(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    -0x10(%rbp),%rax
je     11c5 <touch_file_page+0x75>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x18(%rbp),%ecx
mov    %eax,%r8d
lea    0xe56(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x1b,%edx
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     1221 <touch_file_page+0xd1>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%r8d
lea    0xece(%rip),%rdi
lea    0xe1d(%rip),%rsi
mov    $0x20,%edx
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touch_file_page>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %dl,0x7(%rsp)
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    %rbx,%rax
jne    118c <touch_file_page+0x3c>
lea    0x7(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    11b1 <touch_file_page+0x61>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e4d(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
lea    0xe5d(%rip),%rdi
lea    0xe80(%rip),%rsi
mov    $0x1b,%edx
jmp    11d4 <touch_file_page+0x84>
mov    0x2e28(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
lea    0xf0c(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x20,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1050 <test_msg@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [42 x i8] c"ERR: %s:%d: Lseek fail (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/unlink_mmap01.c\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"ERR: %s:%d: Write fail (errno = %d (%s))\0A\00"
define void @touch_file_page(i32 %0, i64 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8
store i32 %0, i32* %4
store i64 %1, i64* %5
store i8 %2, i8* %6
%7 = load i32, i32* %4
%8 = load i64, i64* %5
%9 = load i32, i32* @SEEK_SET
%10 = call i64 @lseek(i32 %7, i64 %8, i32 %9)
%11 = load i64, i64* %5
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i32, i32* @errno
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @test_msg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 %14, i32 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %3
%20 = load i32, i32* %4
%21 = call i32 @write(i32 %20, i8* %6, i32 1)
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* @errno
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 @test_msg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %24, i32 %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [42 x i8] c"ERR: %s:%d: Lseek fail (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/unlink_mmap01.c\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"ERR: %s:%d: Write fail (errno = %d (%s))\0A\00"
define void @touch_file_page(i32 %0, i64 %1, i8 signext %2) {
%4 = alloca i8
store i8 %2, i8* %4
%5 = load i32, i32* @SEEK_SET
%6 = tail call i64 @lseek(i32 %0, i64 %1, i32 %5)
%7 = icmp eq i64 %6, %1
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 @test_msg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 %9, i32 %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %3
%14 = call i32 @write(i32 %0, i8* %4, i32 1)
%15 = icmp eq i32 %14, 1
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = load i32, i32* @errno
%18 = tail call i32 @strerror(i32 %17)
%19 = tail call i32 @test_msg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %17, i32 %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %13
ret void
}