#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",
            argv[0]);
    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 * 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
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe90(%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    0xe6d(%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    0xe5b(%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    0xe32(%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    0xe31(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe1c(%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    0xdec(%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    0xda3(%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
imul   -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
je     13db <main+0x26b>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd73(%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
mov    %rsi,%r15
cmp    $0x4,%edi
jne    1271 <main+0x101>
mov    0x8(%r15),%rdi
lea    0xec6(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1286 <main+0x116>
mov    0x8(%r15),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     129c <main+0x12c>
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    12c1 <main+0x151>
mov    0x10(%r15),%rdi
lea    0xefa(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
mov    0x18(%r15),%rdi
lea    0xee8(%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     12d7 <main+0x167>
mov    (%rsp),%ebp
cltd
idiv   %esi
cmp    $0xffffffff,%ebp
je     1237 <main+0xc7>
cmp    %eax,%ebp
jg     1318 <main+0x1a8>
mov    %ebp,%eax
jmp    123a <main+0xca>
mov    %eax,(%rsp)
mov    %ebx,0x10(%rsp)
imul   %esi,%eax
mov    %eax,0x14(%rsp)
mov    0x2d7c(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   1040 <ioctl@plt>
test   %rax,%rax
jne    12eb <main+0x17b>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xd7c(%rip),%rsi
jmp    12b0 <main+0x140>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xdc6(%rip),%rsi
jmp    12b0 <main+0x140>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xdef(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xde9(%rip),%rsi
jmp    12ff <main+0x18f>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
mov    %ebx,%edx
jmp    132c <main+0x1bc>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2cb1(%rip),%rcx
mov    (%rcx),%edi
lea    0xde0(%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 = [9 x i8] c"/dev/mtd\00"
@.str.2 = [63 x i8] c"'%s' is not a MTD device. Must specify mtd device: /dev/mtd?\0A\00"
@O_RDWR = global i32 0
@.str.3 = [31 x i8] c"Could not open mtd device: %s\0A\00"
@MEMGETINFO = global i32 0
@.str.4 = [39 x i8] c"Could not get MTD device info from %s\0A\00"
@.str.5 = [3 x i8] c"%x\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [29 x i8] c"%x is beyond device size %x\0A\00"
@.str.8 = [45 x i8] c"%d are too many sectors, device only has %d\0A\00"
@MEMLOCK = global i32 0
@.str.9 = [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 %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %20
br label %34
34: ; preds = %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDWR
%39 = call i32 @open(i8* %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %34
%50 = load i32, i32* %6
%51 = load i32, i32* @MEMGETINFO
%52 = call i64 @ioctl(i32 %50, i32 %51, %struct.mtd_info_user* %7)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = load i32, i32* %6
%61 = call i32 @close(i32 %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %49
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 2
%66 = load i8*, i8** %65
%67 = call i32 @sscanf(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %10)
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 3
%70 = load i8*, i8** %69
%71 = call i32 @sscanf(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %9)
%72 = load i32, i32* %10
%73 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%74 = load i32, i32* %73
%75 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%76 = load i32, i32* %75
%77 = sub nsw i32 %74, %76
%78 = icmp sgt i32 %72, %77
br i1 %78, label %79, label %89
79: ; preds = %63
%80 = load i32, i32* @stderr
%81 = load i32, i32* %10
%82 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%83 = load i32, i32* %82
%84 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%85 = load i32, i32* %84
%86 = sub nsw i32 %83, %85
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %81, i32 %86)
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %63
%90 = load i32, i32* %9
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %98
92: ; preds = %89
%93 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%94 = load i32, i32* %93
%95 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%96 = load i32, i32* %95
%97 = sdiv i32 %94, %96
store i32 %97, i32* %9
br label %117
98: ; preds = %89
%99 = load i32, i32* %9
%100 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%103 = load i32, i32* %102
%104 = sdiv i32 %101, %103
%105 = icmp sgt i32 %99, %104
br i1 %105, label %106, label %116
106: ; preds = %98
%107 = load i32, i32* @stderr
%108 = load i32, i32* %9
%109 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 0
%110 = load i32, i32* %109
%111 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%112 = load i32, i32* %111
%113 = sdiv i32 %110, %112
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %108, i32 %113)
%115 = call i32 @exit(i32 1)
unreachable
116: ; preds = %98
br label %117
117: ; preds = %116, %92
%118 = load i32, i32* %10
%119 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %8, i32 0, i32 2
store i32 %118, i32* %119
%120 = load i32, i32* %9
%121 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %7, i32 0, i32 1
%122 = load i32, i32* %121
%123 = mul nsw i32 %120, %122
%124 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %8, i32 0, i32 3
store i32 %123, i32* %124
%125 = load i32, i32* %6
%126 = load i32, i32* @MEMLOCK
%127 = bitcast %struct.erase_info_user* %8 to %struct.mtd_info_user*
%128 = call i64 @ioctl(i32 %125, i32 %126, %struct.mtd_info_user* %127)
%129 = icmp ne i64 %128, 0
br i1 %129, label %130, label %139
130: ; preds = %117
%131 = load i32, i32* @stderr
%132 = load i8**, i8*** %5
%133 = getelementptr inbounds i8*, i8** %132, i64 1
%134 = load i8*, i8** %133
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %134)
%136 = load i32, i32* %6
%137 = call i32 @close(i32 %136)
%138 = call i32 @exit(i32 1)
unreachable
139: ; preds = %117
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 = [9 x i8] c"/dev/mtd\00"
@.str.2 = [63 x i8] c"'%s' is not a MTD device. Must specify mtd device: /dev/mtd?\0A\00"
@O_RDWR = global i32 0
@.str.3 = [31 x i8] c"Could not open mtd device: %s\0A\00"
@MEMGETINFO = global i32 0
@.str.4 = [39 x i8] c"Could not get MTD device info from %s\0A\00"
@.str.5 = [3 x i8] c"%x\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [29 x i8] c"%x is beyond device size %x\0A\00"
@.str.8 = [45 x i8] c"%d are too many sectors, device only has %d\0A\00"
@MEMLOCK = global i32 0
@.str.9 = [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 %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %18
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %17
%28 = load i8*, i8** %18
%29 = load i32, i32* @O_RDWR
%30 = tail call i32 @open(i8* %28, i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %18
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %27
%38 = load i32, i32* @MEMGETINFO
%39 = call i64 @ioctl(i32 %30, i32 %38, %struct.mtd_info_user* %3)
%40 = icmp eq i64 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %18
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = call i32 @close(i32 %30)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %37
%48 = getelementptr inbounds i8*, i8** %1, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%51 = getelementptr inbounds i8*, i8** %1, i64 3
%52 = load i8*, i8** %51
%53 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%54 = load i32, i32* %6
%55 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %3, i64 0, i32 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.mtd_info_user, %struct.mtd_info_user* %3, i64 0, i32 1
%58 = load i32, i32* %57
%59 = sub nsw i32 %56, %58
%60 = icmp sgt i32 %54, %59
br i1 %60, label %61, label %65
61: ; preds = %47
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %54, i32 %59)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %47
%66 = load i32, i32* %5
%67 = icmp eq i32 %66, -1
%68 = sdiv i32 %56, %58
br i1 %67, label %69, label %70
69: ; preds = %65
store i32 %68, i32* %5
br label %76
70: ; preds = %65
%71 = icmp sgt i32 %66, %68
br i1 %71, label %72, label %76
72: ; preds = %70
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %66, i32 %68)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %70, %69
%77 = phi i32 [ %66, %70 ], [ %68, %69 ]
%78 = getelementptr inbounds %struct.erase_info_user, %struct.erase_info_user* %4, i64 0, i32 2
store i32 %54, i32* %78
%79 = mul nsw i32 %77, %58
%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 %30, i32 %81, %struct.mtd_info_user* %82)
%84 = icmp eq i64 %83, 0
br i1 %84, label %91, label %85
85: ; preds = %76
%86 = load i32, i32* @stderr
%87 = load i8*, i8** %18
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %87)
%89 = call i32 @close(i32 %30)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %76
ret i32 0
}