#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 scalar_t__ off_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EINVAL;
int ERANGE;
int MTD_OTP_FACTORY;
int MTD_OTP_USER;
int /*<<< orphan*/ OTPSELECT;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ioctl(int, int /*<<< orphan*/, int *);
scalar_t__ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
scalar_t__ strtoull(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int fd, val, i, ret;
  int offset = 0;
  unsigned char buf[16];
  if (argc <= 3 || (strcmp(argv[1], "-f") && strcmp(argv[1], "-u"))) {
    fprintf(stderr, "Usage: %s [ -f | -u ] <device> [<offset>]\n",
            "flash_otp_dump");
    return EINVAL;
  }
  fd = open(argv[2], O_RDONLY);
  if (fd < 0) {
    perror(argv[2]);
    return errno;
  }
  val = argv[1][1] == 'f' ? MTD_OTP_FACTORY : MTD_OTP_USER;
  ret = ioctl(fd, OTPSELECT, &val);
  if (ret < 0) {
    perror("OTPSELECT");
    return errno;
  }
  if (argc >= 4) {
    char *p;
    offset = (off_t)strtoull(argv[3], &p, 0);
    if (argv[3][0] == 0 || *p != 0) {
      fprintf(stderr, "%s: bad offset value\n", "flash_otp_dump");
      return ERANGE;
    }
  }
  if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
    perror("lseek()");
    return errno;
  }
  printf("OTP %s data for %s\n", argv[1][1] == 'f' ? "factory" : "user",
         argv[2]);
  while ((ret = read(fd, buf, sizeof(buf)))) {
    if (ret < 0) {
      perror("read()");
      return errno;
    }
    printf("0x%04x:", offset);
    for (i = 0; i < ret; i++)
      printf(" %02x", buf[i]);
    printf("\n");
    offset += ret;
  }
  close(fd);
  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)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1203 <main+0x63>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1230 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0f(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1230 <main+0x90>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
lea    0xe17(%rip),%rdx
call   10a0 <fprintf@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1271 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <perror@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x66,%eax
jne    1297 <main+0xf7>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    12a3 <main+0x103>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    12e8 <main+0x148>
lea    0xd6e(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
cmpl   $0x4,-0x8(%rbp)
jl     135e <main+0x1be>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x48(%rbp),%rsi
xor    %edx,%edx
call   1080 <strtoull@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     132c <main+0x18c>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1359 <main+0x1b9>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
lea    0xcee(%rip),%rdx
call   10a0 <fprintf@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
jmp    135e <main+0x1be>
mov    -0x14(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    0x2c3d(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    $0xffffffffffffffff,%rax
jne    1399 <main+0x1f9>
lea    0xcdd(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%ecx
lea    0xcd8(%rip),%rsi
lea    0xcc9(%rip),%rax
cmp    $0x66,%ecx
cmove  %rax,%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1070 <read@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1479 <main+0x2d9>
cmpl   $0x0,-0x20(%rbp)
jge    1414 <main+0x274>
lea    0xc8b(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1488 <main+0x2e8>
mov    -0x24(%rbp),%esi
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    145d <main+0x2bd>
movslq -0x1c(%rbp),%rax
movzbl -0x40(%rbp,%rax,1),%esi
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    142c <main+0x28c>
lea    0xbcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    13d0 <main+0x230>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x4,%edi
jl     11f0 <main+0x40>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe2f(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1218 <main+0x68>
mov    0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1218 <main+0x68>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
lea    0xe2a(%rip),%rdx
call   10b0 <fprintf@plt>
mov    0x2d8d(%rip),%rax
jmp    12bc <main+0x10c>
mov    0x10(%rbp),%rdi
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
test   %eax,%eax
js     13ad <main+0x1fd>
mov    %eax,%r12d
mov    0x8(%rbp),%rax
cmpb   $0x66,0x1(%rax)
jne    1248 <main+0x98>
mov    0x2db2(%rip),%rax
jmp    124f <main+0x9f>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
call   1060 <ioctl@plt>
test   %eax,%eax
js     13b3 <main+0x203>
mov    0x18(%rbp),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1090 <strtoull@plt>
mov    %rax,%r13
mov    0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1299 <main+0xe9>
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
je     12cd <main+0x11d>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
lea    0xd81(%rip),%rdx
call   10b0 <fprintf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd4(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
mov    %r13d,%esi
call   1050 <lseek@plt>
cmp    $0xffffffffffffffff,%rax
je     13cb <main+0x21b>
mov    0x8(%rbp),%rax
mov    0x10(%rbp),%rdx
cmpb   $0x66,0x1(%rax)
lea    0xd7e(%rip),%rax
lea    0xd7f(%rip),%rsi
cmove  %rax,%rsi
lea    0xd58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0x10,%edx
call   1080 <read@plt>
test   %eax,%eax
je     139e <main+0x1ee>
mov    %eax,%ebp
lea    0xd62(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
test   %ebp,%ebp
js     13d4 <main+0x224>
lea    0xd41(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%r15d
xor    %r14d,%r14d
nop
movzbl 0x10(%rsp,%r14,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    1360 <main+0x1b0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %ebp,%r13d
mov    %r12d,%edi
lea    0x10(%rsp),%rsi
mov    $0x10,%edx
call   1080 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1340 <main+0x190>
mov    %r12d,%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    12be <main+0x10e>
mov    0x10(%rbp),%rdi
jmp    13ba <main+0x20a>
lea    0xc86(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2bea(%rip),%rax
jmp    12bc <main+0x10c>
lea    0xc8e(%rip),%rdi
jmp    13ba <main+0x20a>
lea    0xcae(%rip),%rdi
jmp    13ba <main+0x20a>

LLVM IR (-O0):
@.str = [3 x i8] c"-f\00"
@.str.1 = [3 x i8] c"-u\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"Usage: %s [ -f | -u ] <device> [<offset>]\0A\00"
@.str.3 = [15 x i8] c"flash_otp_dump\00"
@EINVAL = global i32 0
@O_RDONLY = global i32 0
@errno = global i32 0
@MTD_OTP_FACTORY = global i32 0
@MTD_OTP_USER = global i32 0
@OTPSELECT = global i32 0
@.str.4 = [10 x i8] c"OTPSELECT\00"
@.str.5 = [22 x i8] c"%s: bad offset value\0A\00"
@ERANGE = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [8 x i8] c"lseek()\00"
@.str.7 = [20 x i8] c"OTP %s data for %s\0A\00"
@.str.8 = [8 x i8] c"factory\00"
@.str.9 = [5 x i8] c"user\00"
@.str.10 = [7 x i8] c"read()\00"
@.str.11 = [8 x i8] c"0x%04x:\00"
@.str.12 = [6 x i8] c" %02x\00"
@.str.13 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [16 x i8]
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 3
br i1 %14, label %27, label %15
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21, %2
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EINVAL
store i32 %30, i32* %3
br label %152
31: ; preds = %21, %15
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i32, i32* @O_RDONLY
%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 %45
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @perror(i8* %42)
%44 = load i32, i32* @errno
store i32 %44, i32* %3
br label %152
45: ; preds = %31
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 102
br i1 %52, label %53, label %55
53: ; preds = %45
%54 = load i32, i32* @MTD_OTP_FACTORY
br label %57
55: ; preds = %45
%56 = load i32, i32* @MTD_OTP_USER
br label %57
57: ; preds = %55, %53
%58 = phi i32 [ %54, %53 ], [ %56, %55 ]
store i32 %58, i32* %7
%59 = load i32, i32* %6
%60 = load i32, i32* @OTPSELECT
%61 = call i32 @ioctl(i32 %59, i32 %60, i32* %7)
store i32 %61, i32* %9
%62 = load i32, i32* %9
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* @errno
store i32 %66, i32* %3
br label %152
67: ; preds = %57
%68 = load i32, i32* %4
%69 = icmp sge i32 %68, 4
br i1 %69, label %70, label %93
70: ; preds = %67
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 3
%73 = load i8*, i8** %72
%74 = call i64 @strtoull(i8* %73, i8** %12, i32 0)
%75 = trunc i64 %74 to i32
store i32 %75, i32* %10
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 3
%78 = load i8*, i8** %77
%79 = getelementptr inbounds i8, i8* %78, i64 0
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 0
br i1 %82, label %88, label %83
83: ; preds = %70
%84 = load i8*, i8** %12
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %83, %70
%89 = load i32, i32* @stderr
%90 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%91 = load i32, i32* @ERANGE
store i32 %91, i32* %3
br label %152
92: ; preds = %83
br label %93
93: ; preds = %92, %67
%94 = load i32, i32* %6
%95 = load i32, i32* %10
%96 = load i32, i32* @SEEK_SET
%97 = call i64 @lseek(i32 %94, i32 %95, i32 %96)
%98 = icmp eq i64 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %93
%100 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%101 = load i32, i32* @errno
store i32 %101, i32* %3
br label %152
102: ; preds = %93
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 1
%105 = load i8*, i8** %104
%106 = getelementptr inbounds i8, i8* %105, i64 1
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 102
%110 = zext i1 %109 to i64
%111 = select i1 %109, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0)
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 2
%114 = load i8*, i8** %113
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %111, i8* %114)
br label %116
116: ; preds = %144, %102
%117 = load i32, i32* %6
%118 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%119 = call i32 @read(i32 %117, i8* %118, i32 16)
store i32 %119, i32* %9
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %149
121: ; preds = %116
%122 = load i32, i32* %9
%123 = icmp slt i32 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %121
%125 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%126 = load i32, i32* @errno
store i32 %126, i32* %3
br label %152
127: ; preds = %121
%128 = load i32, i32* %10
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %128)
store i32 0, i32* %8
br label %130
130: ; preds = %141, %127
%131 = load i32, i32* %8
%132 = load i32, i32* %9
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %144
134: ; preds = %130
%135 = load i32, i32* %8
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %136
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %139)
br label %141
141: ; preds = %134
%142 = load i32, i32* %8
%143 = add nsw i32 %142, 1
store i32 %143, i32* %8
br label %130
144: ; preds = %130
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%146 = load i32, i32* %9
%147 = load i32, i32* %10
%148 = add nsw i32 %147, %146
store i32 %148, i32* %10
br label %116
149: ; preds = %116
%150 = load i32, i32* %6
%151 = call i32 @close(i32 %150)
store i32 0, i32* %3
br label %152
152: ; preds = %149, %124, %99, %88, %64, %39, %27
%153 = load i32, i32* %3
ret i32 %153
}

LLVM IR (-O2):
@.str = [3 x i8] c"-f\00"
@.str.1 = [3 x i8] c"-u\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"Usage: %s [ -f | -u ] <device> [<offset>]\0A\00"
@.str.3 = [15 x i8] c"flash_otp_dump\00"
@EINVAL = global i32 0
@O_RDONLY = global i32 0
@errno = global i32 0
@MTD_OTP_FACTORY = global i32 0
@MTD_OTP_USER = global i32 0
@OTPSELECT = global i32 0
@.str.4 = [10 x i8] c"OTPSELECT\00"
@.str.5 = [22 x i8] c"%s: bad offset value\0A\00"
@ERANGE = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [8 x i8] c"lseek()\00"
@.str.7 = [20 x i8] c"OTP %s data for %s\0A\00"
@.str.8 = [8 x i8] c"factory\00"
@.str.9 = [5 x i8] c"user\00"
@.str.10 = [7 x i8] c"read()\00"
@.str.11 = [8 x i8] c"0x%04x:\00"
@.str.12 = [6 x i8] c" %02x\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [16 x i8]
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%8 = icmp slt i32 %0, 4
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14, %2
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* @EINVAL
br label %105
22: ; preds = %14, %9
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = tail call i32 @open(i8* %24, i32 %25)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i8*, i8** %23
%30 = tail call i32 @perror(i8* %29)
%31 = load i32, i32* @errno
br label %105
32: ; preds = %22
%33 = load i8*, i8** %10
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 102
%37 = load i32, i32* @MTD_OTP_FACTORY
%38 = load i32, i32* @MTD_OTP_USER
%39 = select i1 %36, i32 %37, i32 %38
store i32 %39, i32* %3
%40 = load i32, i32* @OTPSELECT
%41 = call i32 @ioctl(i32 %26, i32 %40, i32* %3)
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %32
%44 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%45 = load i32, i32* @errno
br label %105
46: ; preds = %32
%47 = bitcast i8** %5 to i8*
%48 = getelementptr inbounds i8*, i8** %1, i64 3
%49 = load i8*, i8** %48
%50 = call i64 @strtoull(i8* %49, i8** %5, i32 0)
%51 = trunc i64 %50 to i32
%52 = load i8*, i8** %48
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %46
%56 = load i8*, i8** %5
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, 0
br i1 %58, label %63, label %59
59: ; preds = %46, %55
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* @ERANGE
br label %105
63: ; preds = %55
%64 = load i32, i32* @SEEK_SET
%65 = call i64 @lseek(i32 %26, i32 %51, i32 %64)
%66 = icmp eq i64 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%69 = load i32, i32* @errno
br label %105
70: ; preds = %63
%71 = load i8*, i8** %10
%72 = getelementptr inbounds i8, i8* %71, i64 1
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 102
%75 = select i1 %74, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0)
%76 = load i8*, i8** %23
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %75, i8* %76)
%78 = call i32 @read(i32 %26, i8* %7, i32 16)
%79 = icmp eq i32 %78, 0
br i1 %79, label %103, label %80
80: ; preds = %70, %98
%81 = phi i32 [ %101, %98 ], [ %78, %70 ]
%82 = phi i32 [ %100, %98 ], [ %51, %70 ]
%83 = icmp slt i32 %81, 0
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%86 = load i32, i32* @errno
br label %105
87: ; preds = %80
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %82)
%89 = zext i32 %81 to i64
br label %90
90: ; preds = %87, %90
%91 = phi i64 [ 0, %87 ], [ %96, %90 ]
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = zext i8 %93 to i32
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %94)
%96 = add nuw nsw i64 %91, 1
%97 = icmp eq i64 %96, %89
br i1 %97, label %98, label %90
98: ; preds = %90
%99 = call i32 @putchar(i32 10)
%100 = add nsw i32 %81, %82
%101 = call i32 @read(i32 %26, i8* %7, i32 16)
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %80
103: ; preds = %98, %70
%104 = call i32 @close(i32 %26)
br label %105
105: ; preds = %59, %103, %84, %67, %43, %28, %18
%106 = phi i32 [ %21, %18 ], [ %31, %28 ], [ %45, %43 ], [ %69, %67 ], [ %86, %84 ], [ 0, %103 ], [ %62, %59 ]
ret i32 %106
}