#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*/ perror(char *);
int /*<<< orphan*/ print_test_stage_ok();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_blocking_queue_overflow();
int /*<<< orphan*/ test_blocking_rw();
int /*<<< orphan*/ test_nonblocking_w();
int /*<<< orphan*/ test_size_set(size_t);
int /*<<< orphan*/ test_vsd_poll();
int /*<<< orphan*/ vsd_deinit();
int /*<<< orphan*/ vsd_get_size(size_t *);
int /*<<< orphan*/ vsd_init();
int main() {
  size_t vsd_initial_size = 0;
  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/vsd4/vsd_userspace/vsd_test.c",
            151);
    perror("Test failed");
    abort();
  };
  if (!(!vsd_get_size(&vsd_initial_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/vsd4/vsd_userspace/vsd_test.c",
            152);
    perror("Test failed");
    abort();
  };
  test_size_set(vsd_initial_size);
  test_blocking_rw();
  print_test_stage_ok();
  test_blocking_queue_overflow();
  test_nonblocking_w();
  print_test_stage_ok();
  test_size_set(vsd_initial_size / 2);
  test_blocking_rw();
  print_test_stage_ok();
  test_size_set(vsd_initial_size / 4);
  test_blocking_rw();
  print_test_stage_ok();
  test_vsd_poll();
  print_test_stage_ok();
  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/vsd4/vsd_userspace/vsd_test.c",
            172);
    perror("Test failed");
    abort();
  };
  printf("Test ok\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <vsd_init@plt>
cmp    $0x0,%eax
je     122b <main+0x5b>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
lea    0xdf9(%rip),%rdx
mov    $0x97,%ecx
call   1090 <fprintf@plt>
lea    0xe9e(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
lea    -0x10(%rbp),%rdi
call   10c0 <vsd_get_size@plt>
cmp    $0x0,%eax
je     1271 <main+0xa1>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdb3(%rip),%rsi
lea    0xdb3(%rip),%rdx
mov    $0x98,%ecx
call   1090 <fprintf@plt>
lea    0xe58(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1050 <test_size_set@plt>
mov    $0x0,%al
call   1030 <test_blocking_rw@plt>
mov    $0x0,%al
call   10f0 <print_test_stage_ok@plt>
mov    $0x0,%al
call   10d0 <test_blocking_queue_overflow@plt>
mov    $0x0,%al
call   1070 <test_nonblocking_w@plt>
mov    $0x0,%al
call   10f0 <print_test_stage_ok@plt>
mov    -0x10(%rbp),%rdi
shr    $0x1,%rdi
call   1050 <test_size_set@plt>
mov    $0x0,%al
call   1030 <test_blocking_rw@plt>
mov    $0x0,%al
call   10f0 <print_test_stage_ok@plt>
mov    -0x10(%rbp),%rdi
shr    $0x2,%rdi
call   1050 <test_size_set@plt>
mov    $0x0,%al
call   1030 <test_blocking_rw@plt>
mov    $0x0,%al
call   10f0 <print_test_stage_ok@plt>
mov    $0x0,%al
call   10b0 <test_vsd_poll@plt>
mov    $0x0,%al
call   10f0 <print_test_stage_ok@plt>
mov    $0x0,%al
call   1060 <vsd_deinit@plt>
cmp    $0x0,%eax
je     1325 <main+0x155>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
lea    0xcff(%rip),%rsi
lea    0xcff(%rip),%rdx
mov    $0xac,%ecx
call   1090 <fprintf@plt>
lea    0xda4(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
lea    0xd9d(%rip),%rdi
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
xor    %eax,%eax
call   10a0 <vsd_init@plt>
test   %eax,%eax
jne    1282 <main+0xb2>
mov    %rsp,%rdi
call   10c0 <vsd_get_size@plt>
test   %eax,%eax
jne    12a0 <main+0xd0>
mov    (%rsp),%rdi
call   1050 <test_size_set@plt>
xor    %eax,%eax
call   1030 <test_blocking_rw@plt>
xor    %eax,%eax
call   10f0 <print_test_stage_ok@plt>
xor    %eax,%eax
call   10d0 <test_blocking_queue_overflow@plt>
xor    %eax,%eax
call   1080 <test_nonblocking_w@plt>
xor    %eax,%eax
call   10f0 <print_test_stage_ok@plt>
mov    (%rsp),%rdi
shr    %rdi
call   1050 <test_size_set@plt>
xor    %eax,%eax
call   1030 <test_blocking_rw@plt>
xor    %eax,%eax
call   10f0 <print_test_stage_ok@plt>
mov    (%rsp),%rdi
shr    $0x2,%rdi
call   1050 <test_size_set@plt>
xor    %eax,%eax
call   1030 <test_blocking_rw@plt>
xor    %eax,%eax
call   10f0 <print_test_stage_ok@plt>
xor    %eax,%eax
call   10b0 <test_vsd_poll@plt>
xor    %eax,%eax
call   10f0 <print_test_stage_ok@plt>
xor    %eax,%eax
call   1070 <vsd_deinit@plt>
test   %eax,%eax
jne    12be <main+0xee>
lea    0xe50(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xd6e(%rip),%rsi
lea    0xd6e(%rip),%rdx
mov    $0x97,%ecx
jmp    12da <main+0x10a>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
lea    0xd50(%rip),%rdx
mov    $0x98,%ecx
jmp    12da <main+0x10a>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
lea    0xd32(%rip),%rdx
mov    $0xac,%ecx
call   1090 <fprintf@plt>
lea    0xdd7(%rip),%rdi
call   10e0 <perror@plt>
xor    %eax,%eax
call   1040 <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/vsd4/vsd_userspace/vsd_test.c\00"
@.str.2 = [12 x i8] c"Test failed\00"
@.str.3 = [9 x i8] c"Test ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
%3 = call i32 (...) @vsd_init()
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, 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 151)
%8 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i32 @vsd_get_size(i64* %2)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, 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 152)
%16 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %10
%19 = load i64, i64* %2
%20 = call i32 @test_size_set(i64 %19)
%21 = call i32 (...) @test_blocking_rw()
%22 = call i32 (...) @print_test_stage_ok()
%23 = call i32 (...) @test_blocking_queue_overflow()
%24 = call i32 (...) @test_nonblocking_w()
%25 = call i32 (...) @print_test_stage_ok()
%26 = load i64, i64* %2
%27 = udiv i64 %26, 2
%28 = call i32 @test_size_set(i64 %27)
%29 = call i32 (...) @test_blocking_rw()
%30 = call i32 (...) @print_test_stage_ok()
%31 = load i64, i64* %2
%32 = udiv i64 %31, 4
%33 = call i32 @test_size_set(i64 %32)
%34 = call i32 (...) @test_blocking_rw()
%35 = call i32 (...) @print_test_stage_ok()
%36 = call i32 (...) @test_vsd_poll()
%37 = call i32 (...) @print_test_stage_ok()
%38 = call i32 (...) @vsd_deinit()
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %18
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, 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 172)
%43 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %18
%46 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 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/vsd4/vsd_userspace/vsd_test.c\00"
@.str.2 = [12 x i8] c"Test failed\00"
@str = [8 x i8] c"Test ok\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call i32 (...) @vsd_init()
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, 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 151)
%8 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i32 @vsd_get_size(i64* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, 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 152)
%16 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %10
%19 = load i64, i64* %1
%20 = call i32 @test_size_set(i64 %19)
%21 = call i32 (...) @test_blocking_rw()
%22 = call i32 (...) @print_test_stage_ok()
%23 = call i32 (...) @test_blocking_queue_overflow()
%24 = call i32 (...) @test_nonblocking_w()
%25 = call i32 (...) @print_test_stage_ok()
%26 = load i64, i64* %1
%27 = lshr i64 %26, 1
%28 = call i32 @test_size_set(i64 %27)
%29 = call i32 (...) @test_blocking_rw()
%30 = call i32 (...) @print_test_stage_ok()
%31 = load i64, i64* %1
%32 = lshr i64 %31, 2
%33 = call i32 @test_size_set(i64 %32)
%34 = call i32 (...) @test_blocking_rw()
%35 = call i32 (...) @print_test_stage_ok()
%36 = call i32 (...) @test_vsd_poll()
%37 = call i32 (...) @print_test_stage_ok()
%38 = call i32 (...) @vsd_deinit()
%39 = icmp eq i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %18
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, 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 172)
%43 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %18
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}