#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*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ driver_set_operation(char *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fsync(int);
int ftell(int /*<<< orphan*/ *);
int handle_error_bad_file(char *);
int /*<<< orphan*/ memset(char *, char, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int mtx_to_driver() {
  int sim_fd = open("/sys/devices/platform/brtablet/data", O_RDWR);
  if (sim_fd < 0) {
    return (-1);
  }
  int i, j, w, temp;
  char buff[500];
  FILE *fp = fopen("/etc/brtablet/coef", "r");
  if (fp == NULL) {
    return (-1);
  }
  int ini = 0;
  memset(buff, ' ', sizeof(buff));
  for (i = 0; i < (5 - 1) * (5 - 1) * 2; i++) {
    for (j = 0; j < 3; j++) {
      for (w = 0; w < 3; w++) {
        if (fscanf(fp, "%d", &temp) < 1) {
          return handle_error_bad_file("/etc/brtablet/coef");
        }
        sprintf(buff, "%d", temp);
      }
    }
    int fim = ftell(fp);
    fseek(fp, ini, SEEK_SET);
    if (fread(buff, 1, fim - ini + 1, fp) < fim - ini + 1)
      return -1;
    buff[fim - ini + 1] = 0;
    fseek(fp, fim, SEEK_SET);
    driver_set_operation("/sys/devices/platform/brtablet/operation", 1, i);
    write(sim_fd, buff, fim - ini + 1);
    ini = fim + 1;
    fsync(sim_fd);
  }
  fclose(fp);
  close(sim_fd);
  return (0);
}


x86 assembly (clang, -O0):
<mtx_to_driver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
lea    0xe05(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1219 <mtx_to_driver+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <mtx_to_driver+0x248>
lea    0xe04(%rip),%rdi
lea    0xe10(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    124d <mtx_to_driver+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <mtx_to_driver+0x248>
movl   $0x0,-0x21c(%rbp)
lea    -0x210(%rbp),%rdi
mov    $0x20,%esi
mov    $0x1f4,%edx
call   1080 <memset@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    140d <mtx_to_driver+0x22d>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    130b <mtx_to_driver+0x12b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    12f8 <mtx_to_driver+0x118>
mov    -0x218(%rbp),%rdi
lea    0xd8b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1090 <fscanf@plt>
cmp    $0x1,%eax
jge    12d4 <mtx_to_driver+0xf4>
lea    0xd5d(%rip),%rdi
call   1040 <handle_error_bad_file@plt>
mov    %eax,-0x4(%rbp)
jmp    1428 <mtx_to_driver+0x248>
lea    -0x210(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xd54(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1296 <mtx_to_driver+0xb6>
jmp    12fd <mtx_to_driver+0x11d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1285 <mtx_to_driver+0xa5>
mov    -0x218(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %eax,-0x220(%rbp)
mov    -0x218(%rbp),%rdi
mov    -0x21c(%rbp),%esi
mov    0x2ca7(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
lea    -0x210(%rbp),%rdi
mov    -0x220(%rbp),%edx
sub    -0x21c(%rbp),%edx
add    $0x1,%edx
mov    -0x218(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x220(%rbp),%ecx
sub    -0x21c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1382 <mtx_to_driver+0x1a2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1428 <mtx_to_driver+0x248>
mov    -0x220(%rbp),%eax
sub    -0x21c(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x210(%rbp,%rax,1)
mov    -0x218(%rbp),%rdi
mov    -0x220(%rbp),%esi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
mov    -0xc(%rbp),%edx
lea    0xc7c(%rip),%rdi
mov    $0x1,%esi
call   1030 <driver_set_operation@plt>
mov    -0x8(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    -0x220(%rbp),%edx
sub    -0x21c(%rbp),%edx
add    $0x1,%edx
call   1060 <write@plt>
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x21c(%rbp)
mov    -0x8(%rbp),%edi
call   10d0 <fsync@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1274 <mtx_to_driver+0x94>
mov    -0x218(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x8(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtx_to_driver>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
lea    0xdff(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
js     146d <mtx_to_driver+0x28d>
lea    0xe0b(%rip),%rdi
lea    0xe17(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r13
mov    $0xffffffff,%eax
test   %r13,%r13
je     1480 <mtx_to_driver+0x2a0>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x20,%esi
mov    $0x1f4,%edx
call   1080 <memset@plt>
xor    %r15d,%r15d
lea    0xde2(%rip),%rbp
lea    0x4(%rsp),%rbx
xor    %r12d,%r12d
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <fscanf@plt>
test   %eax,%eax
jle    1474 <mtx_to_driver+0x294>
mov    %r12d,0xc(%rsp)
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1100 <sprintf@plt>
mov    %r13,%rdi
call   10b0 <ftell@plt>
mov    %r15d,%ebx
mov    %eax,%r15d
mov    0x2c12(%rip),%r12
mov    (%r12),%edx
mov    %r13,%rdi
mov    %ebx,%esi
call   10c0 <fseek@plt>
mov    %r15d,%eax
sub    %ebx,%eax
movslq %eax,%rbx
lea    0x1(%rbx),%rbp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
cmp    %ebx,%eax
jle    146d <mtx_to_driver+0x28d>
movb   $0x0,0x10(%rsp,%rbp,1)
mov    (%r12),%edx
mov    %r13,%rdi
mov    %r15d,%esi
call   10c0 <fseek@plt>
lea    0xc2b(%rip),%rdi
mov    $0x1,%esi
mov    0xc(%rsp),%r12d
mov    %r12d,%edx
call   1030 <driver_set_operation@plt>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1060 <write@plt>
add    $0x1,%r15d
mov    %ebx,%edi
call   10d0 <fsync@plt>
add    $0x1,%r12d
cmp    $0x20,%r12d
lea    0x4(%rsp),%rbx
lea    0xbe7(%rip),%rbp
jne    125f <mtx_to_driver+0x7f>
mov    %r13,%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
jmp    1480 <mtx_to_driver+0x2a0>
mov    $0xffffffff,%eax
jmp    1480 <mtx_to_driver+0x2a0>
lea    0xba9(%rip),%rdi
call   1040 <handle_error_bad_file@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"/sys/devices/platform/brtablet/data\00"
@O_RDWR = global i32 0
@.str.1 = [19 x i8] c"/etc/brtablet/coef\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.4 = [41 x i8] c"/sys/devices/platform/brtablet/operation\00"
define i32 @mtx_to_driver() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [500 x i8]
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 -1, i32* %1
br label %104
16: ; preds = %0
%17 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %1
br label %104
21: ; preds = %16
store i32 0, i32* %9
%22 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%23 = call i32 @memset(i8* %22, i8 signext 32, i32 500)
store i32 0, i32* %3
br label %24
24: ; preds = %96, %21
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 32
br i1 %26, label %27, label %99
27: ; preds = %24
store i32 0, i32* %4
br label %28
28: ; preds = %49, %27
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %52
31: ; preds = %28
store i32 0, i32* %5
br label %32
32: ; preds = %45, %31
%33 = load i32, i32* %5
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = load i32*, i32** %8
%37 = call i32 @fscanf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%38 = icmp slt i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @handle_error_bad_file(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 %40, i32* %1
br label %104
41: ; preds = %35
%42 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%43 = load i32, i32* %6
%44 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %41
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %32
48: ; preds = %32
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %28
52: ; preds = %28
%53 = load i32*, i32** %8
%54 = call i32 @ftell(i32* %53)
store i32 %54, i32* %10
%55 = load i32*, i32** %8
%56 = load i32, i32* %9
%57 = load i32, i32* @SEEK_SET
%58 = call i32 @fseek(i32* %55, i32 %56, i32 %57)
%59 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%60 = load i32, i32* %10
%61 = load i32, i32* %9
%62 = sub nsw i32 %60, %61
%63 = add nsw i32 %62, 1
%64 = load i32*, i32** %8
%65 = call i32 @fread(i8* %59, i32 1, i32 %63, i32* %64)
%66 = load i32, i32* %10
%67 = load i32, i32* %9
%68 = sub nsw i32 %66, %67
%69 = add nsw i32 %68, 1
%70 = icmp slt i32 %65, %69
br i1 %70, label %71, label %72
71: ; preds = %52
store i32 -1, i32* %1
br label %104
72: ; preds = %52
%73 = load i32, i32* %10
%74 = load i32, i32* %9
%75 = sub nsw i32 %73, %74
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 %77
store i8 0, i8* %78
%79 = load i32*, i32** %8
%80 = load i32, i32* %10
%81 = load i32, i32* @SEEK_SET
%82 = call i32 @fseek(i32* %79, i32 %80, i32 %81)
%83 = load i32, i32* %3
%84 = call i32 @driver_set_operation(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %83)
%85 = load i32, i32* %2
%86 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%87 = load i32, i32* %10
%88 = load i32, i32* %9
%89 = sub nsw i32 %87, %88
%90 = add nsw i32 %89, 1
%91 = call i32 @write(i32 %85, i8* %86, i32 %90)
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 1
store i32 %93, i32* %9
%94 = load i32, i32* %2
%95 = call i32 @fsync(i32 %94)
br label %96
96: ; preds = %72
%97 = load i32, i32* %3
%98 = add nsw i32 %97, 1
store i32 %98, i32* %3
br label %24
99: ; preds = %24
%100 = load i32*, i32** %8
%101 = call i32 @fclose(i32* %100)
%102 = load i32, i32* %2
%103 = call i32 @close(i32 %102)
store i32 0, i32* %1
br label %104
104: ; preds = %99, %71, %39, %20, %15
%105 = load i32, i32* %1
ret i32 %105
}

LLVM IR (-O2):
@.str = [36 x i8] c"/sys/devices/platform/brtablet/data\00"
@O_RDWR = global i32 0
@.str.1 = [19 x i8] c"/etc/brtablet/coef\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.4 = [41 x i8] c"/sys/devices/platform/brtablet/operation\00"
define i32 @mtx_to_driver() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %86, label %6
6: ; preds = %0
%7 = bitcast i32* %1 to i8*
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %84, label %11
11: ; preds = %6
%12 = call i32 @memset(i8* %8, i8 signext 32, i32 500)
br label %13
13: ; preds = %11, %70
%14 = phi i32 [ 0, %11 ], [ %77, %70 ]
%15 = phi i32 [ 0, %11 ], [ %79, %70 ]
%16 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %55, %50, %45, %40, %35, %30, %25, %20, %13
%19 = call i32 @handle_error_bad_file(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %84
20: ; preds = %13
%21 = load i32, i32* %1
%22 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%24 = icmp slt i32 %23, 1
br i1 %24, label %18, label %25
25: ; preds = %20
%26 = load i32, i32* %1
%27 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%29 = icmp slt i32 %28, 1
br i1 %29, label %18, label %30
30: ; preds = %25
%31 = load i32, i32* %1
%32 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%34 = icmp slt i32 %33, 1
br i1 %34, label %18, label %35
35: ; preds = %30
%36 = load i32, i32* %1
%37 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%39 = icmp slt i32 %38, 1
br i1 %39, label %18, label %40
40: ; preds = %35
%41 = load i32, i32* %1
%42 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%44 = icmp slt i32 %43, 1
br i1 %44, label %18, label %45
45: ; preds = %40
%46 = load i32, i32* %1
%47 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%49 = icmp slt i32 %48, 1
br i1 %49, label %18, label %50
50: ; preds = %45
%51 = load i32, i32* %1
%52 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%54 = icmp slt i32 %53, 1
br i1 %54, label %18, label %55
55: ; preds = %50
%56 = load i32, i32* %1
%57 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%59 = icmp slt i32 %58, 1
br i1 %59, label %18, label %60
60: ; preds = %55
%61 = load i32, i32* %1
%62 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = call i32 @ftell(i32* %9)
%64 = load i32, i32* @SEEK_SET
%65 = call i32 @fseek(i32* %9, i32 %14, i32 %64)
%66 = sub nsw i32 %63, %14
%67 = add nsw i32 %66, 1
%68 = call i32 @fread(i8* %8, i32 1, i32 %67, i32* %9)
%69 = icmp sgt i32 %68, %66
br i1 %69, label %70, label %84
70: ; preds = %60
%71 = sext i32 %67 to i64
%72 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %71
store i8 0, i8* %72
%73 = load i32, i32* @SEEK_SET
%74 = call i32 @fseek(i32* %9, i32 %63, i32 %73)
%75 = call i32 @driver_set_operation(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %15)
%76 = call i32 @write(i32 %4, i8* %8, i32 %67)
%77 = add nsw i32 %63, 1
%78 = call i32 @fsync(i32 %4)
%79 = add nuw nsw i32 %15, 1
%80 = icmp eq i32 %79, 32
br i1 %80, label %81, label %13
81: ; preds = %70
%82 = call i32 @fclose(i32* %9)
%83 = call i32 @close(i32 %4)
br label %84
84: ; preds = %60, %18, %81, %6
%85 = phi i32 [ -1, %6 ], [ %19, %18 ], [ 0, %81 ], [ -1, %60 ]
br label %86
86: ; preds = %0, %84
%87 = phi i32 [ %85, %84 ], [ -1, %0 ]
ret i32 %87
}