#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 */
typedef int /*<<< orphan*/ nr_hugepages;
typedef int /*<<< orphan*/ initial_nr_hugepages;

/* Variables and functions */
int O_NONBLOCK;
int O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int write(int, char *, int);
int check_compaction(unsigned long mem_free, unsigned int hugepage_size) {
  int fd;
  int compaction_index = 0;
  char initial_nr_hugepages[10] = {0};
  char nr_hugepages[10] = {0};
  mem_free = mem_free * 0.8;
  fd = open("/proc/sys/vm/nr_hugepages", O_RDWR | O_NONBLOCK);
  if (fd < 0) {
    perror("Failed to open /proc/sys/vm/nr_hugepages");
    return -1;
  }
  if (read(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages)) <= 0) {
    perror("Failed to read from /proc/sys/vm/nr_hugepages");
    goto close_fd;
  }
  if (write(fd, "0", sizeof(char)) != sizeof(char)) {
    perror("Failed to write 0 to /proc/sys/vm/nr_hugepages\n");
    goto close_fd;
  }
  lseek(fd, 0, SEEK_SET);
  if (write(fd, "100000", (6 * sizeof(char))) != (6 * sizeof(char))) {
    perror("Failed to write 100000 to /proc/sys/vm/nr_hugepages\n");
    goto close_fd;
  }
  lseek(fd, 0, SEEK_SET);
  if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
    perror("Failed to re-read from /proc/sys/vm/nr_hugepages\n");
    goto close_fd;
  }
  compaction_index = mem_free / (atoi(nr_hugepages) * hugepage_size);
  if (compaction_index > 3) {
    printf("No of huge pages allocated = %d\n", (atoi(nr_hugepages)));
    fprintf(stderr,
            "ERROR: Less that 1/%d of memory is available\n"
            "as huge pages\n",
            compaction_index);
    goto close_fd;
  }
  printf("No of huge pages allocated = %d\n", (atoi(nr_hugepages)));
  lseek(fd, 0, SEEK_SET);
  if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages)) !=
      strlen(initial_nr_hugepages)) {
    perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
    goto close_fd;
  }
  close(fd);
  return 0;
close_fd:
  close(fd);
  printf("Not OK. Compaction test failed.");
  return -1;
}


x86 assembly (clang, -O0):
<check_compaction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movw   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movw   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movaps 0xe27(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe26(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xe0c(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
mov    0x2da1(%rip),%rax
or     (%rax),%esi
lea    0xe25(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1272 <check_compaction+0xd2>
lea    0xdcf(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1463 <check_compaction+0x2c3>
mov    -0x18(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jg     129e <check_compaction+0xfe>
lea    0xdc5(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <check_compaction+0x2a6>
mov    -0x18(%rbp),%edi
lea    0xe14(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cltq
cmp    $0x1,%rax
je     12cf <check_compaction+0x12f>
lea    0xdc2(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <check_compaction+0x2a6>
mov    -0x18(%rbp),%edi
mov    0x2cef(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    -0x18(%rbp),%edi
lea    0xdcb(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cltq
cmp    $0x6,%rax
je     1313 <check_compaction+0x173>
lea    0xdb5(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <check_compaction+0x2a6>
mov    -0x18(%rbp),%edi
mov    0x2cab(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jg     1352 <check_compaction+0x1b2>
lea    0xdab(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <check_compaction+0x2a6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x38(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
imul   -0x14(%rbp),%ecx
mov    %ecx,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jle    13b7 <check_compaction+0x217>
lea    -0x38(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xd99(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1446 <check_compaction+0x2a6>
lea    -0x38(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%esi
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
mov    0x2bee(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x44(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
je     1432 <check_compaction+0x292>
lea    0xd5a(%rip),%rdi
call   10b0 <perror@plt>
jmp    1446 <check_compaction+0x2a6>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1463 <check_compaction+0x2c3>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_compaction>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    0x2e10(%rip),%rax
mov    0x2e01(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe83(%rip),%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     1366 <check_compaction+0x1c6>
mov    %eax,%ebx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0xa,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    1374 <check_compaction+0x1d4>
lea    0xea2(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
jne    137d <check_compaction+0x1dd>
mov    0x2d92(%rip),%r12
mov    (%r12),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
lea    0xe6d(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
jne    1386 <check_compaction+0x1e6>
mov    (%r12),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    138f <check_compaction+0x1ef>
movq   %r15,%xmm0
punpckldq 0xd6f(%rip),%xmm0
subpd  0xd77(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xd73(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xd67(%rip),%xmm1
cvttsd2si %xmm1,%rbp
and    %rcx,%rbp
or     %rax,%rbp
mov    %rsp,%rdi
call   10c0 <atoi@plt>
mov    %eax,%esi
imul   %eax,%r14d
mov    %rbp,%rax
shr    $0x20,%rax
je     12f0 <check_compaction+0x150>
mov    %rbp,%rax
xor    %edx,%edx
div    %r14
mov    %rax,%rbp
jmp    12f9 <check_compaction+0x159>
mov    %ebp,%eax
xor    %edx,%edx
div    %r14d
mov    %eax,%ebp
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x4,%ebp
jl     1325 <check_compaction+0x185>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
mov    %ebp,%edx
call   1090 <fprintf@plt>
jmp    13a4 <check_compaction+0x204>
mov    (%r12),%edx
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jne    1398 <check_compaction+0x1f8>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    13be <check_compaction+0x21e>
lea    0xcc3(%rip),%rdi
call   10b0 <perror@plt>
jmp    13b9 <check_compaction+0x219>
lea    0xcde(%rip),%rdi
jmp    139f <check_compaction+0x1ff>
lea    0xd03(%rip),%rdi
jmp    139f <check_compaction+0x1ff>
lea    0xd31(%rip),%rdi
jmp    139f <check_compaction+0x1ff>
lea    0xd5d(%rip),%rdi
jmp    139f <check_compaction+0x1ff>
lea    0xde3(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"/proc/sys/vm/nr_hugepages\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [41 x i8] c"Failed to open /proc/sys/vm/nr_hugepages\00"
@.str.2 = [46 x i8] c"Failed to read from /proc/sys/vm/nr_hugepages\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [48 x i8] c"Failed to write 0 to /proc/sys/vm/nr_hugepages\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [7 x i8] c"100000\00"
@.str.6 = [53 x i8] c"Failed to write 100000 to /proc/sys/vm/nr_hugepages\0A\00"
@.str.7 = [50 x i8] c"Failed to re-read from /proc/sys/vm/nr_hugepages\0A\00"
@.str.8 = [33 x i8] c"No of huge pages allocated = %d\0A\00"
@stderr = global i32 0
@.str.9 = [60 x i8] c"ERROR: Less that 1/%d of memory is available\0Aas huge pages\0A\00"
@.str.10 = [52 x i8] c"Failed to write value to /proc/sys/vm/nr_hugepages\0A\00"
@.str.11 = [32 x i8] c"Not OK. Compaction test failed.\00"
define i32 @check_compaction(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca [10 x i8]
store i64 %0, i64* %4
store i32 %1, i32* %5
store i32 0, i32* %7
%10 = bitcast [10 x i8]* %8 to i8*
%11 = bitcast [10 x i8]* %9 to i8*
%12 = load i64, i64* %4
%13 = uitofp i64 %12 to double
%14 = fmul double %13, 8.000000e-01
%15 = fptoui double %14 to i64
store i64 %15, i64* %4
%16 = load i32, i32* @O_RDWR
%17 = load i32, i32* @O_NONBLOCK
%18 = or i32 %16, %17
%19 = call i32 @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %100
24: ; preds = %2
%25 = load i32, i32* %6
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%27 = call i64 @read(i32 %25, i8* %26, i32 10)
%28 = icmp sle i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %96
31: ; preds = %24
%32 = load i32, i32* %6
%33 = call i32 @write(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%34 = sext i32 %33 to i64
%35 = icmp ne i64 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %96
38: ; preds = %31
%39 = load i32, i32* %6
%40 = load i32, i32* @SEEK_SET
%41 = call i32 @lseek(i32 %39, i32 0, i32 %40)
%42 = load i32, i32* %6
%43 = call i32 @write(i32 %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%44 = sext i32 %43 to i64
%45 = icmp ne i64 %44, 6
br i1 %45, label %46, label %48
46: ; preds = %38
%47 = call i32 @perror(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
br label %96
48: ; preds = %38
%49 = load i32, i32* %6
%50 = load i32, i32* @SEEK_SET
%51 = call i32 @lseek(i32 %49, i32 0, i32 %50)
%52 = load i32, i32* %6
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%54 = call i64 @read(i32 %52, i8* %53, i32 10)
%55 = icmp sle i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %48
%57 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %96
58: ; preds = %48
%59 = load i64, i64* %4
%60 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%61 = call i32 @atoi(i8* %60)
%62 = load i32, i32* %5
%63 = mul i32 %61, %62
%64 = zext i32 %63 to i64
%65 = udiv i64 %59, %64
%66 = trunc i64 %65 to i32
store i32 %66, i32* %7
%67 = load i32, i32* %7
%68 = icmp sgt i32 %67, 3
br i1 %68, label %69, label %76
69: ; preds = %58
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%71 = call i32 @atoi(i8* %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %71)
%73 = load i32, i32* @stderr
%74 = load i32, i32* %7
%75 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 %74)
br label %96
76: ; preds = %58
%77 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%78 = call i32 @atoi(i8* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %6
%81 = load i32, i32* @SEEK_SET
%82 = call i32 @lseek(i32 %80, i32 0, i32 %81)
%83 = load i32, i32* %6
%84 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%85 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%86 = call i32 @strlen(i8* %85)
%87 = call i32 @write(i32 %83, i8* %84, i32 %86)
%88 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%89 = call i32 @strlen(i8* %88)
%90 = icmp ne i32 %87, %89
br i1 %90, label %91, label %93
91: ; preds = %76
%92 = call i32 @perror(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
br label %96
93: ; preds = %76
%94 = load i32, i32* %6
%95 = call i32 @close(i32 %94)
store i32 0, i32* %3
br label %100
96: ; preds = %91, %69, %56, %46, %36, %29
%97 = load i32, i32* %6
%98 = call i32 @close(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
br label %100
100: ; preds = %96, %93, %22
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [26 x i8] c"/proc/sys/vm/nr_hugepages\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [41 x i8] c"Failed to open /proc/sys/vm/nr_hugepages\00"
@.str.2 = [46 x i8] c"Failed to read from /proc/sys/vm/nr_hugepages\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [48 x i8] c"Failed to write 0 to /proc/sys/vm/nr_hugepages\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [7 x i8] c"100000\00"
@.str.6 = [53 x i8] c"Failed to write 100000 to /proc/sys/vm/nr_hugepages\0A\00"
@.str.7 = [50 x i8] c"Failed to re-read from /proc/sys/vm/nr_hugepages\0A\00"
@.str.8 = [33 x i8] c"No of huge pages allocated = %d\0A\00"
@stderr = global i32 0
@.str.9 = [60 x i8] c"ERROR: Less that 1/%d of memory is available\0Aas huge pages\0A\00"
@.str.10 = [52 x i8] c"Failed to write value to /proc/sys/vm/nr_hugepages\0A\00"
@.str.11 = [32 x i8] c"Not OK. Compaction test failed.\00"
define i32 @check_compaction(i64 %0, i32 %1) {
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = uitofp i64 %0 to double
%8 = fmul double %7, 8.000000e-01
%9 = fptoui double %8 to i64
%10 = load i32, i32* @O_RDWR
%11 = load i32, i32* @O_NONBLOCK
%12 = or i32 %11, %10
%13 = tail call i32 @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = tail call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %66
17: ; preds = %2
%18 = call i64 @read(i32 %13, i8* %5, i32 10)
%19 = icmp slt i64 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %63
22: ; preds = %17
%23 = tail call i32 @write(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %63
27: ; preds = %22
%28 = load i32, i32* @SEEK_SET
%29 = tail call i32 @lseek(i32 %13, i32 0, i32 %28)
%30 = tail call i32 @write(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%31 = icmp eq i32 %30, 6
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = tail call i32 @perror(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
br label %63
34: ; preds = %27
%35 = load i32, i32* @SEEK_SET
%36 = tail call i32 @lseek(i32 %13, i32 0, i32 %35)
%37 = call i64 @read(i32 %13, i8* %6, i32 10)
%38 = icmp slt i64 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = tail call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %63
41: ; preds = %34
%42 = call i32 @atoi(i8* %6)
%43 = mul i32 %42, %1
%44 = zext i32 %43 to i64
%45 = udiv i64 %9, %44
%46 = trunc i64 %45 to i32
%47 = icmp sgt i32 %46, 3
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %42)
br i1 %47, label %49, label %52
49: ; preds = %41
%50 = load i32, i32* @stderr
%51 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 %46)
br label %63
52: ; preds = %41
%53 = load i32, i32* @SEEK_SET
%54 = tail call i32 @lseek(i32 %13, i32 0, i32 %53)
%55 = call i32 @strlen(i8* %5)
%56 = call i32 @write(i32 %13, i8* %5, i32 %55)
%57 = call i32 @strlen(i8* %5)
%58 = icmp eq i32 %56, %57
br i1 %58, label %61, label %59
59: ; preds = %52
%60 = call i32 @perror(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
br label %63
61: ; preds = %52
%62 = call i32 @close(i32 %13)
br label %66
63: ; preds = %59, %49, %39, %32, %25, %20
%64 = call i32 @close(i32 %13)
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %66
66: ; preds = %63, %61, %15
%67 = phi i32 [ -1, %15 ], [ -1, %63 ], [ 0, %61 ]
ret i32 %67
}