#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 */
struct mtd_info_user {
  int size;
  int erasesize;
  int start;
  int length;
};
struct erase_info_user {
  int size;
  int erasesize;
  int start;
  int length;
};

/* Variables and functions */
int /*<<< orphan*/ MEMGETINFO;
int /*<<< orphan*/ MEMLOCK;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct mtd_info_user *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  struct mtd_info_user mtdInfo;
  struct erase_info_user mtdLockInfo;
  int num_sectors;
  int ofs;
  if (argc != 4) {
    fprintf(stderr,
            "USAGE: %s <mtd device> <ofs in hex> <num of sectors in decimal or "
            "-1 for all sectors>\n",
            "flash_lock");
    exit(1);
  } else if (strncmp(argv[1], "/dev/mtd", 8) != 0) {
    fprintf(stderr,
            "'%s' is not a MTD device.  Must specify mtd device: /dev/mtd?\n",
            argv[1]);
    exit(1);
  }
  fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "Could not open mtd device: %s\n", argv[1]);
    exit(1);
  }
  if (ioctl(fd, MEMGETINFO, &mtdInfo)) {
    fprintf(stderr, "Could not get MTD device info from %s\n", argv[1]);
    close(fd);
    exit(1);
  }
  sscanf(argv[2], "%x", &ofs);
  sscanf(argv[3], "%d", &num_sectors);
  if (ofs > mtdInfo.size - mtdInfo.erasesize) {
    fprintf(stderr, "%x is beyond device size %x\n", ofs,
            (unsigned int)(mtdInfo.size - mtdInfo.erasesize));
    exit(1);
  }
  if (num_sectors == -1) {
    num_sectors = mtdInfo.size / mtdInfo.erasesize;
  } else {
    if (num_sectors > mtdInfo.size / mtdInfo.erasesize) {
      fprintf(stderr, "%d are too many sectors, device only has %d\n",
              num_sectors, (int)(mtdInfo.size / mtdInfo.erasesize));
      exit(1);
    }
  }
  mtdLockInfo.start = ofs;
  mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize;
  if (ioctl(fd, MEMLOCK, &mtdLockInfo)) {
    fprintf(stderr, "Could not lock MTD device: %s\n", argv[1]);
    close(fd);
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11b8 <main+0x48>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
lea    0xeb0(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1204 <main+0x94>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1209 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1255 <main+0xe5>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d81(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
je     12a5 <main+0x135>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3c(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe27(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x40(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jle    1310 <main+0x1a0>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
mov    -0x28(%rbp),%ecx
sub    -0x24(%rbp),%ecx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1329 <main+0x1b9>
mov    -0x28(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,-0x3c(%rbp)
jmp    137b <main+0x20b>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jle    1376 <main+0x206>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    -0x48(%rbp),%edx
mov    %eax,%ecx
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    137b <main+0x20b>
mov    -0x40(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c30(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
je     13de <main+0x26e>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x4,%edi
jne    1274 <main+0x104>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
lea    0xed1(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    128d <main+0x11d>
mov    0x8(%r15),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     12a3 <main+0x133>
mov    %eax,%r14d
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %r14d,%edi
call   1040 <ioctl@plt>
test   %rax,%rax
jne    12c8 <main+0x158>
mov    0x10(%r15),%rdi
lea    0xf05(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
mov    0x18(%r15),%rdi
lea    0xef3(%rip),%rsi
mov    %rsp,%rdx
call   1070 <sscanf@plt>
mov    0x4(%rsp),%ebx
mov    0x18(%rsp),%eax
mov    0x1c(%rsp),%esi
mov    %eax,%ecx
sub    %esi,%ecx
cmp    %ecx,%ebx
jg     12de <main+0x16e>
mov    (%rsp),%ebp
cltd
idiv   %esi
cmp    $0xffffffff,%ebp
je     1237 <main+0xc7>
cmp    %eax,%ebp
jg     131f <main+0x1af>
mov    %ebp,%eax
jmp    123a <main+0xca>
mov    %eax,(%rsp)
mov    %ebx,0x10(%rsp)
add    $0xffffffff,%eax
imul   %esi,%eax
mov    %eax,0x14(%rsp)
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   1040 <ioctl@plt>
test   %rax,%rax
jne    12f2 <main+0x182>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
lea    0xdcc(%rip),%rdx
jmp    12b7 <main+0x147>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xdca(%rip),%rsi
jmp    12b7 <main+0x147>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xded(%rip),%rsi
jmp    1306 <main+0x196>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
mov    %ebx,%edx
jmp    1333 <main+0x1c3>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe3a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2caa(%rip),%rcx
mov    (%rcx),%edi
lea    0xde4(%rip),%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.mtd_info_user = type { i32, i32, i32, i32 }
%struct.erase_info_user = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [87 x i8] c"USAGE: %s <mtd device> <ofs in hex> <num of sectors in decimal or -1 for all sectors>\0A\00"
@.str.1 = [11 x i8] c"flash_lock\00"
@.str.2 = [9 x i8] c"/dev/mtd\00"
@.str.3 = [63 x i8] c"'%s' is not a MTD device. Must specify mtd device: /dev/mtd?\0A\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Could not open mtd device: %s\0A\00"
@MEMGETINFO = global i32 0
@.str.5 = [39 x i8] c"Could not get MTD device info from %s\0A\00"
@.str.6 = [3 x i8] c"%x\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [29 x i8] c"%x is beyond device size %x\0A\00"
@.str.9 = [45 x i8] c"%d are too many sectors, device only has %d\0A\00"
@MEMLOCK = global i32 0
@.str.10 = [31 x i8] c"Could not lock MTD device: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.mtd_info_user
%8 = alloca %struct.erase_info_user
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 4
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* @O_RDWR
%36 = call i32 @open(i8* %34, i32 %35)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %31
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %31
%47 = load i32, i32* %6
%48 = load i32, i32* @MEMGETINFO
%49 = call i64 @ioctl(i32 %47, i32 %48, %struct.mtd_info_user* %7)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %46
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = load i32, i32* %6
%58 = call i32 @close(i32 %57)
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %46
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i32 @sscanf(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %10)
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 3
%67 = load i8*, i8** %66
%68 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %9)
%69 = load i32, i32* %10
%70 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%71 = load i32, i32* %70
%72 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%73 = load i32, i32* %72
%74 = sub nsw i32 %71, %73
%75 = icmp sgt i32 %69, %74
br i1 %75, label %76, label %86
76: ; preds = %60
%77 = load i32, i32* @stderr
%78 = load i32, i32* %10
%79 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%82 = load i32, i32* %81
%83 = sub nsw i32 %80, %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %78, i32 %83)
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %60
%87 = load i32, i32* %9
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %95
89: ; preds = %86
%90 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%91 = load i32, i32* %90
%92 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%93 = load i32, i32* %92
%94 = sdiv i32 %91, %93
store i32 %94, i32* %9
br label %114
95: ; preds = %86
%96 = load i32, i32* %9
%97 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%98 = load i32, i32* %97
%99 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%100 = load i32, i32* %99
%101 = sdiv i32 %98, %100
%102 = icmp sgt i32 %96, %101
br i1 %102, label %103, label %113
103: ; preds = %95
%104 = load i32, i32* @stderr
%105 = load i32, i32* %9
%106 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%107 = load i32, i32* %106
%108 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%109 = load i32, i32* %108
%110 = sdiv i32 %107, %109
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32 %105, i32 %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %95
br label %114
114: ; preds = %113, %89
%115 = load i32, i32* %10
%116 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %8, i32 0, i32 2
store i32 %115, i32* %116
%117 = load i32, i32* %9
%118 = sub nsw i32 %117, 1
%119 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%120 = load i32, i32* %119
%121 = mul nsw i32 %118, %120
%122 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %8, i32 0, i32 3
store i32 %121, i32* %122
%123 = load i32, i32* %6
%124 = load i32, i32* @MEMLOCK
%125 = bitcast %struct.erase_info_user* %8 to %struct.mtd_info_user*
%126 = call i64 @ioctl(i32 %123, i32 %124, %struct.mtd_info_user* %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %137
128: ; preds = %114
%129 = load i32, i32* @stderr
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 1
%132 = load i8*, i8** %131
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %132)
%134 = load i32, i32* %6
%135 = call i32 @close(i32 %134)
%136 = call i32 @exit(i32 1)
unreachable
137: ; preds = %114
ret i32 0
}

LLVM IR (-O2):
%struct.mtd_info_user = type { i32, i32, i32, i32 }
%struct.erase_info_user = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [87 x i8] c"USAGE: %s <mtd device> <ofs in hex> <num of sectors in decimal or -1 for all sectors>\0A\00"
@.str.1 = [11 x i8] c"flash_lock\00"
@.str.2 = [9 x i8] c"/dev/mtd\00"
@.str.3 = [63 x i8] c"'%s' is not a MTD device. Must specify mtd device: /dev/mtd?\0A\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Could not open mtd device: %s\0A\00"
@MEMGETINFO = global i32 0
@.str.5 = [39 x i8] c"Could not get MTD device info from %s\0A\00"
@.str.6 = [3 x i8] c"%x\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [29 x i8] c"%x is beyond device size %x\0A\00"
@.str.9 = [45 x i8] c"%d are too many sectors, device only has %d\0A\00"
@MEMLOCK = global i32 0
@.str.10 = [31 x i8] c"Could not lock MTD device: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.mtd_info_user
%4 = alloca %struct.erase_info_user
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.mtd_info_user* %3 to i8*
%8 = bitcast %struct.erase_info_user* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 4
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %16
%27 = load i8*, i8** %17
%28 = load i32, i32* @O_RDWR
%29 = tail call i32 @open(i8* %27, i32 %28)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %17
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %26
%37 = load i32, i32* @MEMGETINFO
%38 = call i64 @ioctl(i32 %29, i32 %37, %struct.mtd_info_user* %3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %17
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = call i32 @close(i32 %29)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %36
%47 = getelementptr inbounds i8*, i8** %1, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%50 = getelementptr inbounds i8*, i8** %1, i64 3
%51 = load i8*, i8** %50
%52 = call i32 @sscanf(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%53 = load i32, i32* %6
%54 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %3, i64 0, i32 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %3, i64 0, i32 1
%57 = load i32, i32* %56
%58 = sub nsw i32 %55, %57
%59 = icmp sgt i32 %53, %58
br i1 %59, label %60, label %64
60: ; preds = %46
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %53, i32 %58)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %46
%65 = load i32, i32* %5
%66 = icmp eq i32 %65, -1
%67 = sdiv i32 %55, %57
br i1 %66, label %68, label %69
68: ; preds = %64
store i32 %67, i32* %5
br label %75
69: ; preds = %64
%70 = icmp sgt i32 %65, %67
br i1 %70, label %71, label %75
71: ; preds = %69
%72 = load i32, i32* @stderr
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32 %65, i32 %67)
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %69, %68
%76 = phi i32 [ %65, %69 ], [ %67, %68 ]
%77 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %4, i64 0, i32 2
store i32 %53, i32* %77
%78 = add nsw i32 %76, -1
%79 = mul nsw i32 %78, %57
%80 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %4, i64 0, i32 3
store i32 %79, i32* %80
%81 = load i32, i32* @MEMLOCK
%82 = bitcast %struct.erase_info_user* %4 to %struct.mtd_info_user*
%83 = call i64 @ioctl(i32 %29, i32 %81, %struct.mtd_info_user* %82)
%84 = icmp eq i64 %83, 0
br i1 %84, label %91, label %85
85: ; preds = %75
%86 = load i32, i32* @stderr
%87 = load i8*, i8** %17
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* %87)
%89 = call i32 @close(i32 %29)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %75
ret i32 0
}