#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*/ e_f(char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int, int);
scalar_t__ ftruncate(int, int);
int lseek(int, int, int /*<<< orphan*/);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ unlink(char *);
int doseeks(int seekbase) {
  char template[30] = "tempfile.XXXXXXXX";
  int iteration, fd = mkstemp(template);
  int limit = seekbase + 1000;
  if (fd < 0) {
    perror("mkstemp");
    e_f("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/"
        "master/minix-master/minix/tests/test70.c",
        38, (2));
    return 1;
  }
  if (unlink(template) < 0) {
    perror("unlink");
    e_f("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/"
        "master/minix-master/minix/tests/test70.c",
        39, (3));
    return 1;
  }
  if (ftruncate(fd, limit) < 0) {
    perror("ftruncate");
    e_f("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/"
        "master/minix-master/minix/tests/test70.c",
        40, (4));
    return 1;
  }
  for (iteration = 0; iteration < 5000; iteration++) {
    int o;
    for (o = seekbase; o < limit; o++) {
      int r;
      if ((r = lseek(fd, o, SEEK_SET)) != o) {
        if (r < 0)
          perror("lseek");
        fprintf(stderr, "%d/%d  %d != %d\n", iteration, 5000, r, o);
        e_f("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/"
            "heads/master/minix-master/minix/tests/test70.c",
            55, (5));
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<doseeks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe7b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe78(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe76(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xe70(%rip),%ax
mov    %ax,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
call   1070 <mkstemp@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
add    $0x3e8,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    11ff <doseeks+0x8f>
lea    0xe46(%rip),%rdi
call   1090 <perror@plt>
lea    0xe42(%rip),%rdi
mov    $0x26,%esi
mov    $0x2,%edx
call   1080 <e_f@plt>
movl   $0x1,-0x4(%rbp)
jmp    1353 <doseeks+0x1e3>
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    1240 <doseeks+0xd0>
lea    0xebc(%rip),%rdi
call   1090 <perror@plt>
lea    0xe01(%rip),%rdi
mov    $0x27,%esi
mov    $0x3,%edx
call   1080 <e_f@plt>
movl   $0x1,-0x4(%rbp)
jmp    1353 <doseeks+0x1e3>
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <ftruncate@plt>
cmp    $0x0,%rax
jge    1283 <doseeks+0x113>
lea    0xe80(%rip),%rdi
call   1090 <perror@plt>
lea    0xdbe(%rip),%rdi
mov    $0x28,%esi
mov    $0x4,%edx
call   1080 <e_f@plt>
movl   $0x1,-0x4(%rbp)
jmp    1353 <doseeks+0x1e3>
movl   $0x0,-0x34(%rbp)
cmpl   $0x1388,-0x34(%rbp)
jge    134c <doseeks+0x1dc>
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1339 <doseeks+0x1c9>
mov    -0x38(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    %eax,-0x44(%rbp)
cmp    -0x40(%rbp),%eax
je     1326 <doseeks+0x1b6>
cmpl   $0x0,-0x44(%rbp)
jge    12df <doseeks+0x16f>
lea    0xe0c(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x44(%rbp),%r8d
mov    -0x40(%rbp),%r9d
lea    0xdf2(%rip),%rsi
mov    $0x1388,%ecx
call   1060 <fprintf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x37,%esi
mov    $0x5,%edx
call   1080 <e_f@plt>
movl   $0x1,-0x4(%rbp)
jmp    1353 <doseeks+0x1e3>
jmp    132b <doseeks+0x1bb>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    129d <doseeks+0x12d>
jmp    133e <doseeks+0x1ce>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    128a <doseeks+0x11a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doseeks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
movups 0xe87(%rip),%xmm0
movups %xmm0,0x1e(%rsp)
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1070 <mkstemp@plt>
test   %eax,%eax
js     1276 <doseeks+0x106>
mov    %eax,%r12d
lea    0x10(%rsp),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
js     1295 <doseeks+0x125>
lea    0x3e8(%rbx),%r13d
mov    %r12d,%edi
mov    %r13d,%esi
call   1040 <ftruncate@plt>
test   %rax,%rax
js     12b4 <doseeks+0x144>
xor    %r15d,%r15d
mov    0x2df3(%rip),%r14
mov    %rbx,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edx
mov    %r12d,%edi
mov    %ebx,%esi
call   1050 <lseek@plt>
cmp    %eax,%ebx
jne    121f <doseeks+0xaf>
add    $0x1,%ebx
cmp    %r13d,%ebx
jl     11f0 <doseeks+0x80>
add    $0x1,%r15d
cmp    $0x1388,%r15d
mov    0x8(%rsp),%rbx
jne    11ea <doseeks+0x7a>
xor    %eax,%eax
jmp    1267 <doseeks+0xf7>
mov    %eax,%ebp
test   %eax,%eax
js     12d3 <doseeks+0x163>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
mov    %r15d,%edx
mov    $0x1388,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
call   1060 <fprintf@plt>
lea    0xdd3(%rip),%rdi
mov    $0x37,%esi
mov    $0x5,%edx
call   1080 <e_f@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda1(%rip),%rdi
call   1090 <perror@plt>
lea    0xd9d(%rip),%rdi
mov    $0x26,%esi
mov    $0x2,%edx
jmp    125d <doseeks+0xed>
lea    0xe39(%rip),%rdi
call   1090 <perror@plt>
lea    0xd7e(%rip),%rdi
mov    $0x27,%esi
mov    $0x3,%edx
jmp    125d <doseeks+0xed>
lea    0xe21(%rip),%rdi
call   1090 <perror@plt>
lea    0xd5f(%rip),%rdi
mov    $0x28,%esi
mov    $0x4,%edx
jmp    125d <doseeks+0xed>
lea    0xe0c(%rip),%rdi
call   1090 <perror@plt>
jmp    1229 <doseeks+0xb9>

LLVM IR (-O0):
@__const.doseeks.template = [30 x i8] c"tempfile.XXXXXXXX\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"mkstemp\00"
@.str.1 = [175 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/master/minix-master/minix/tests/test70.c\00"
@.str.2 = [7 x i8] c"unlink\00"
@.str.3 = [10 x i8] c"ftruncate\00"
@SEEK_SET = global i32 0
@.str.4 = [6 x i8] c"lseek\00"
@stderr = global i32 0
@.str.5 = [17 x i8] c"%d/%d %d != %d\0A\00"
define i32 @doseeks(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [30 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
%10 = bitcast [30 x i8]* %4 to i8*
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%12 = call i32 @mkstemp(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1000
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 38, i32 2)
store i32 1, i32* %2
br label %73
20: ; preds = %1
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%22 = call i64 @unlink(i8* %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 3)
store i32 1, i32* %2
br label %73
27: ; preds = %20
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i64 @ftruncate(i32 %28, i32 %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 40, i32 4)
store i32 1, i32* %2
br label %73
35: ; preds = %27
store i32 0, i32* %5
br label %36
36: ; preds = %69, %35
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 5000
br i1 %38, label %39, label %72
39: ; preds = %36
%40 = load i32, i32* %3
store i32 %40, i32* %8
br label %41
41: ; preds = %65, %39
%42 = load i32, i32* %8
%43 = load i32, i32* %7
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %68
45: ; preds = %41
%46 = load i32, i32* %6
%47 = load i32, i32* %8
%48 = load i32, i32* @SEEK_SET
%49 = call i32 @lseek(i32 %46, i32 %47, i32 %48)
store i32 %49, i32* %9
%50 = load i32, i32* %8
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %64
52: ; preds = %45
%53 = load i32, i32* %9
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %52
%58 = load i32, i32* @stderr
%59 = load i32, i32* %5
%60 = load i32, i32* %9
%61 = load i32, i32* %8
%62 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %59, i32 5000, i32 %60, i32 %61)
%63 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 5)
store i32 1, i32* %2
br label %73
64: ; preds = %45
br label %65
65: ; preds = %64
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
store i32 %67, i32* %8
br label %41
68: ; preds = %41
br label %69
69: ; preds = %68
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %36
72: ; preds = %36
store i32 0, i32* %2
br label %73
73: ; preds = %72, %57, %32, %24, %17
%74 = load i32, i32* %2
ret i32 %74
}

LLVM IR (-O2):
@__const.doseeks.template = [30 x i8] c"tempfile.XXXXXXXX\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"mkstemp\00"
@.str.1 = [175 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/master/minix-master/minix/tests/test70.c\00"
@.str.2 = [7 x i8] c"unlink\00"
@.str.3 = [10 x i8] c"ftruncate\00"
@SEEK_SET = global i32 0
@.str.4 = [6 x i8] c"lseek\00"
@stderr = global i32 0
@.str.5 = [17 x i8] c"%d/%d %d != %d\0A\00"
define i32 @doseeks(i32 %0) {
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%4 = call i32 @mkstemp(i8* %3)
%5 = add nsw i32 %0, 1000
%6 = icmp slt i32 %4, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 38, i32 2)
br label %43
10: ; preds = %1
%11 = call i64 @unlink(i8* %3)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 39, i32 3)
br label %43
16: ; preds = %10
%17 = call i64 @ftruncate(i32 %4, i32 %5)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 40, i32 4)
br label %43
22: ; preds = %16, %40
%23 = phi i32 [ %41, %40 ], [ 0, %16 ]
br label %24
24: ; preds = %22, %33
%25 = phi i32 [ %0, %22 ], [ %34, %33 ]
%26 = load i32, i32* @SEEK_SET
%27 = call i32 @lseek(i32 %4, i32 %25, i32 %26)
%28 = icmp eq i32 %27, %25
br i1 %28, label %33, label %29
29: ; preds = %24
%30 = icmp slt i32 %27, 0
br i1 %30, label %31, label %36
31: ; preds = %29
%32 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %36
33: ; preds = %24
%34 = add nsw i32 %25, 1
%35 = icmp slt i32 %34, %5
br i1 %35, label %24, label %40
36: ; preds = %29, %31
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 5000, i32 %27, i32 %25)
%39 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 5)
br label %43
40: ; preds = %33
%41 = add nuw nsw i32 %23, 1
%42 = icmp eq i32 %41, 5000
br i1 %42, label %43, label %22
43: ; preds = %40, %36, %19, %13, %7
%44 = phi i32 [ 1, %7 ], [ 1, %13 ], [ 1, %19 ], [ 1, %36 ], [ 0, %40 ]
ret i32 %44
}