#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ getpagesize();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_one_test(size_t const, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vsd_deinit();
int /*<<< orphan*/ vsd_get_size(size_t *);
int /*<<< orphan*/ vsd_init();
int main() {
  if (!(!vsd_init())) {
    fprintf(stderr, "%s %d\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/eabatalov/au-linux-kernel-autumn-2017/"
            "refs/heads/master/tasks/vsd2/vsd_userspace/vsd_test.c",
            48);
    perror("Test failed");
    abort();
  };
  const size_t PAGE_SIZE = (size_t)getpagesize();
  size_t vsd_size = 0;
  if (!(!vsd_get_size(&vsd_size))) {
    fprintf(stderr, "%s %d\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/eabatalov/au-linux-kernel-autumn-2017/"
            "refs/heads/master/tasks/vsd2/vsd_userspace/vsd_test.c",
            52);
    perror("Test failed");
    abort();
  };
  run_one_test(0, vsd_size);
  run_one_test(PAGE_SIZE, vsd_size - PAGE_SIZE);
  if (!(!vsd_deinit())) {
    fprintf(stderr, "%s %d\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/eabatalov/au-linux-kernel-autumn-2017/"
            "refs/heads/master/tasks/vsd2/vsd_userspace/vsd_test.c",
            57);
    perror("Test failed");
    abort();
  };
  printf("Ok\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <vsd_init@plt>
cmp    $0x0,%eax
je     11e3 <main+0x53>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
lea    0xe41(%rip),%rdx
mov    $0x30,%ecx
call   1070 <fprintf@plt>
lea    0xee6(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x0,%al
call   10b0 <getpagesize@plt>
cltq
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1090 <vsd_get_size@plt>
cmp    $0x0,%eax
je     123e <main+0xae>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
lea    0xde6(%rip),%rdx
mov    $0x34,%ecx
call   1070 <fprintf@plt>
lea    0xe8b(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <run_one_test@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    -0x10(%rbp),%rsi
call   1040 <run_one_test@plt>
mov    $0x0,%al
call   1050 <vsd_deinit@plt>
cmp    $0x0,%eax
je     12a0 <main+0x110>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
lea    0xd84(%rip),%rdx
mov    $0x39,%ecx
call   1070 <fprintf@plt>
lea    0xe29(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe22(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <vsd_init@plt>
test   %eax,%eax
jne    11fe <main+0x6e>
xor    %eax,%eax
call   10b0 <getpagesize@plt>
mov    %eax,%ebx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1090 <vsd_get_size@plt>
test   %eax,%eax
jne    121c <main+0x8c>
movslq %ebx,%rbx
mov    0x8(%rsp),%rsi
xor    %edi,%edi
call   1050 <run_one_test@plt>
mov    0x8(%rsp),%rsi
sub    %rbx,%rsi
mov    %rbx,%rdi
call   1050 <run_one_test@plt>
xor    %eax,%eax
call   1060 <vsd_deinit@plt>
test   %eax,%eax
jne    123a <main+0xaa>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
lea    0xdf2(%rip),%rdx
mov    $0x30,%ecx
jmp    1256 <main+0xc6>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
lea    0xdd4(%rip),%rdx
mov    $0x34,%ecx
jmp    1256 <main+0xc6>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
lea    0xdb6(%rip),%rdx
mov    $0x39,%ecx
call   1070 <fprintf@plt>
lea    0xe5b(%rip),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"%s %d\0A\00"
@.str.1 = [182 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/eabatalov/au-linux-kernel-autumn-2017/refs/heads/master/tasks/vsd2/vsd_userspace/vsd_test.c\00"
@.str.2 = [12 x i8] c"Test failed\00"
@.str.3 = [4 x i8] c"Ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (...) @vsd_init()
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 48)
%9 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %0
%12 = call i32 (...) @getpagesize()
%13 = sext i32 %12 to i64
store i64 %13, i64* %2
store i64 0, i64* %3
%14 = call i32 @vsd_get_size(i64* %3)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 52)
%19 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %11
%22 = load i64, i64* %3
%23 = call i32 @run_one_test(i64 0, i64 %22)
%24 = load i64, i64* %2
%25 = load i64, i64* %3
%26 = load i64, i64* %2
%27 = sub i64 %25, %26
%28 = call i32 @run_one_test(i64 %24, i64 %27)
%29 = call i32 (...) @vsd_deinit()
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %21
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 57)
%34 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %21
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"%s %d\0A\00"
@.str.1 = [182 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/eabatalov/au-linux-kernel-autumn-2017/refs/heads/master/tasks/vsd2/vsd_userspace/vsd_test.c\00"
@.str.2 = [12 x i8] c"Test failed\00"
@str = [3 x i8] c"Ok\00"
define i32 @main() {
%1 = alloca i64
%2 = tail call i32 (...) @vsd_init()
%3 = icmp eq i32 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 48)
%7 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %0
%10 = tail call i32 (...) @getpagesize()
%11 = sext i32 %10 to i64
%12 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%13 = call i32 @vsd_get_size(i64* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 52)
%18 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %9
%21 = load i64, i64* %1
%22 = call i32 @run_one_test(i64 0, i64 %21)
%23 = load i64, i64* %1
%24 = sub i64 %23, %11
%25 = call i32 @run_one_test(i64 %11, i64 %24)
%26 = call i32 (...) @vsd_deinit()
%27 = icmp eq i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.1, i64 0, i64 0), i32 57)
%31 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %20
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 0
}