#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 */

/* Variables and functions */
int O_RDONLY;
int O_RDWR;
int O_SYNC;
scalar_t__ close(int);
int erase_flash(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int file_to_flash(int, int /*<<< orphan*/, int /*<<< orphan*/, char *);
int flash_to_file(int, int /*<<< orphan*/, int /*<<< orphan*/, char *);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ showinfo(int);
int /*<<< orphan*/ showusage(char const *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strrchr(char *, char);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  const char *progname;
  int err = 0, fd, option = 1;
  int open_flag;
  (progname = strrchr(argv[0], '/')) ? progname++ : (progname = argv[0]);
  if (argc == 3 && !strcmp(argv[1], "info"))
    option = 1;
  else if (argc == 6 && !strcmp(argv[1], "read"))
    option = 2;
  else if (argc == 6 && !strcmp(argv[1], "write"))
    option = 3;
  else if (argc == 5 && !strcmp(argv[1], "erase"))
    option = 4;
  else
    showusage(progname);
  open_flag = (option == 1 || option == 2) ? O_RDONLY : O_RDWR;
  if ((fd = open(argv[2], O_SYNC | open_flag)) < 0) {
    perror("open()");
    exit(1);
  }
  switch (option) {
  case 1:
    showinfo(fd);
    break;
  case 2:
    err = flash_to_file(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0),
                        argv[5]);
    break;
  case 3:
    err = file_to_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0),
                        argv[5]);
    break;
  case 4:
    err = erase_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0));
    break;
  }
  if (close(fd) < 0)
    perror("close()");
  exit(err);
}


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,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1214 <main+0x54>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121f <main+0x5f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1252 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1252 <main+0x92>
movl   $0x1,-0x24(%rbp)
jmp    1303 <main+0x143>
cmpl   $0x6,-0x8(%rbp)
jne    1285 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <main+0xc5>
movl   $0x2,-0x24(%rbp)
jmp    12fe <main+0x13e>
cmpl   $0x6,-0x8(%rbp)
jne    12b8 <main+0xf8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd7c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12b8 <main+0xf8>
movl   $0x3,-0x24(%rbp)
jmp    12f9 <main+0x139>
cmpl   $0x5,-0x8(%rbp)
jne    12eb <main+0x12b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd4f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12eb <main+0x12b>
movl   $0x4,-0x24(%rbp)
jmp    12f4 <main+0x134>
mov    -0x18(%rbp),%rdi
call   10e0 <showusage@plt>
jmp    12f9 <main+0x139>
jmp    12fe <main+0x13e>
jmp    1303 <main+0x143>
cmpl   $0x1,-0x24(%rbp)
je     1317 <main+0x157>
cmpl   $0x2,-0x24(%rbp)
jne    1328 <main+0x168>
mov    0x2cba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1334 <main+0x174>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c97(%rip),%rax
mov    (%rax),%esi
or     -0x28(%rbp),%esi
call   10b0 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    1375 <main+0x1b5>
lea    0xcc0(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     1482 <main+0x2c2>
mov    -0x38(%rbp),%rax
lea    0xc6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%edi
call   1090 <showinfo@plt>
jmp    1482 <main+0x2c2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rcx
call   1030 <flash_to_file@plt>
mov    %eax,-0x1c(%rbp)
jmp    1482 <main+0x2c2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    -0x48(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rcx
call   1060 <file_to_flash@plt>
mov    %eax,-0x1c(%rbp)
jmp    1482 <main+0x2c2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    -0x50(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
call   10a0 <erase_flash@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
cmp    $0x0,%rax
jge    14a0 <main+0x2e0>
lea    0xb92(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbp,%r14
cmp    $0x6,%ebx
je     1227 <main+0x67>
cmp    $0x5,%ebx
je     120c <main+0x4c>
cmp    $0x3,%ebx
jne    1265 <main+0xa5>
mov    0x8(%r15),%rdi
lea    0xe0f(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     126d <main+0xad>
jmp    1265 <main+0xa5>
mov    0x8(%r15),%rdi
lea    0xe09(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1265 <main+0xa5>
mov    $0x4,%ebx
jmp    1261 <main+0xa1>
mov    0x8(%r15),%rbx
lea    0xde3(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1249 <main+0x89>
mov    $0x2,%ebx
mov    $0x1,%cl
xor    %eax,%eax
jmp    1276 <main+0xb6>
lea    0xdca(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1265 <main+0xa5>
mov    $0x3,%ebx
xor    %eax,%eax
jmp    1274 <main+0xb4>
mov    %r14,%rdi
call   10e0 <showusage@plt>
mov    $0x1,%ebx
mov    $0x1,%al
xor    %ecx,%ecx
mov    0x2d5b(%rip),%rsi
mov    %rsi,%rdx
test   %cl,%cl
jne    128b <main+0xcb>
mov    0x2d5d(%rip),%rdx
test   %al,%al
cmovne %rsi,%rdx
mov    0x10(%r15),%rdi
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
or     (%rdx),%esi
call   10b0 <open@plt>
test   %eax,%eax
jns    12bf <main+0xff>
lea    0xd76(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %eax,%ebp
xor    %r14d,%r14d
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
ja     1370 <main+0x1b0>
lea    0xd29(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %ebp,%edi
call   1090 <showinfo@plt>
jmp    1370 <main+0x1b0>
mov    0x18(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,%ebx
mov    0x20(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    0x28(%r15),%rcx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <flash_to_file@plt>
jmp    136d <main+0x1ad>
mov    0x18(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,%ebx
mov    0x20(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    0x28(%r15),%rcx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <file_to_flash@plt>
jmp    136d <main+0x1ad>
mov    0x18(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,%ebx
mov    0x20(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   10a0 <erase_flash@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1050 <close@plt>
test   %rax,%rax
jns    1388 <main+0x1c8>
lea    0xcaa(%rip),%rdi
call   10c0 <perror@plt>
mov    %r14d,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"info\00"
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [6 x i8] c"write\00"
@.str.3 = [6 x i8] c"erase\00"
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.4 = [7 x i8] c"open()\00"
@.str.5 = [8 x i8] c"close()\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 1, i32* %9
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i8* @strrchr(i8* %13, i8 signext 47)
store i8* %14, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %6
br label %23
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
store i8* %22, i8** %6
br label %23
23: ; preds = %19, %16
%24 = phi i8* [ %17, %16 ], [ %22, %19 ]
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %27
store i32 1, i32* %9
br label %70
34: ; preds = %27, %23
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 6
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %37
store i32 2, i32* %9
br label %69
44: ; preds = %37, %34
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 6
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @strcmp(i8* %50, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %47
store i32 3, i32* %9
br label %68
54: ; preds = %47, %44
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 5
br i1 %56, label %57, label %64
57: ; preds = %54
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 @strcmp(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %57
store i32 4, i32* %9
br label %67
64: ; preds = %57, %54
%65 = load i8*, i8** %6
%66 = call i32 @showusage(i8* %65)
br label %67
67: ; preds = %64, %63
br label %68
68: ; preds = %67, %53
br label %69
69: ; preds = %68, %43
br label %70
70: ; preds = %69, %33
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 1
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i32, i32* %9
%75 = icmp eq i32 %74, 2
br i1 %75, label %76, label %78
76: ; preds = %73, %70
%77 = load i32, i32* @O_RDONLY
br label %80
78: ; preds = %73
%79 = load i32, i32* @O_RDWR
br label %80
80: ; preds = %78, %76
%81 = phi i32 [ %77, %76 ], [ %79, %78 ]
store i32 %81, i32* %10
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = load i32, i32* @O_SYNC
%86 = load i32, i32* %10
%87 = or i32 %85, %86
%88 = call i32 @open(i8* %84, i32 %87)
store i32 %88, i32* %8
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %80
%91 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %80
%94 = load i32, i32* %9
switch i32 %94, label %137 [
i32 1, label %95
i32 2, label %98
i32 3, label %112
i32 4, label %126
]
95: ; preds = %93
%96 = load i32, i32* %8
%97 = call i32 @showinfo(i32 %96)
br label %137
98: ; preds = %93
%99 = load i32, i32* %8
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 3
%102 = load i8*, i8** %101
%103 = call i32 @strtol(i8* %102, i32* null, i32 0)
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 4
%106 = load i8*, i8** %105
%107 = call i32 @strtol(i8* %106, i32* null, i32 0)
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 5
%110 = load i8*, i8** %109
%111 = call i32 @flash_to_file(i32 %99, i32 %103, i32 %107, i8* %110)
store i32 %111, i32* %7
br label %137
112: ; preds = %93
%113 = load i32, i32* %8
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 3
%116 = load i8*, i8** %115
%117 = call i32 @strtol(i8* %116, i32* null, i32 0)
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 4
%120 = load i8*, i8** %119
%121 = call i32 @strtol(i8* %120, i32* null, i32 0)
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 5
%124 = load i8*, i8** %123
%125 = call i32 @file_to_flash(i32 %113, i32 %117, i32 %121, i8* %124)
store i32 %125, i32* %7
br label %137
126: ; preds = %93
%127 = load i32, i32* %8
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 3
%130 = load i8*, i8** %129
%131 = call i32 @strtol(i8* %130, i32* null, i32 0)
%132 = load i8**, i8*** %5
%133 = getelementptr inbounds i8*, i8** %132, i64 4
%134 = load i8*, i8** %133
%135 = call i32 @strtol(i8* %134, i32* null, i32 0)
%136 = call i32 @erase_flash(i32 %127, i32 %131, i32 %135)
store i32 %136, i32* %7
br label %137
137: ; preds = %93, %126, %112, %98, %95
%138 = load i32, i32* %8
%139 = call i64 @close(i32 %138)
%140 = icmp slt i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %143
143: ; preds = %141, %137
%144 = load i32, i32* %7
%145 = call i32 @exit(i32 %144)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"info\00"
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [6 x i8] c"write\00"
@.str.3 = [6 x i8] c"erase\00"
@O_RDONLY = global i32 0
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.4 = [7 x i8] c"open()\00"
@.str.5 = [8 x i8] c"close()\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
switch i32 %0, label %26 [
i32 3, label %8
i32 6, label %13
i32 5, label %21
]
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %28, label %26
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %28, label %26
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %23, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %2, %8, %18, %21
%27 = tail call i32 @showusage(i8* %7)
br label %28
28: ; preds = %21, %18, %13, %8, %26
%29 = phi i1 [ true, %26 ], [ true, %8 ], [ false, %13 ], [ false, %18 ], [ false, %21 ]
%30 = phi i1 [ false, %26 ], [ false, %8 ], [ true, %13 ], [ false, %18 ], [ false, %21 ]
%31 = phi i32 [ 1, %26 ], [ 1, %8 ], [ 2, %13 ], [ 3, %18 ], [ 4, %21 ]
%32 = or i1 %29, %30
%33 = load i32, i32* @O_RDONLY
%34 = load i32, i32* @O_RDWR
%35 = select i1 %32, i32 %33, i32 %34
%36 = getelementptr inbounds i8*, i8** %1, i64 2
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_SYNC
%39 = or i32 %38, %35
%40 = tail call i32 @open(i8* %37, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %28
%43 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %28
switch i32 %31, label %76 [
i32 1, label %46
i32 2, label %48
i32 3, label %58
i32 4, label %68
]
46: ; preds = %45
%47 = tail call i32 @showinfo(i32 %40)
br label %76
48: ; preds = %45
%49 = getelementptr inbounds i8*, i8** %1, i64 3
%50 = load i8*, i8** %49
%51 = tail call i32 @strtol(i8* nocapture %50, i32* null, i32 0)
%52 = getelementptr inbounds i8*, i8** %1, i64 4
%53 = load i8*, i8** %52
%54 = tail call i32 @strtol(i8* nocapture %53, i32* null, i32 0)
%55 = getelementptr inbounds i8*, i8** %1, i64 5
%56 = load i8*, i8** %55
%57 = tail call i32 @flash_to_file(i32 %40, i32 %51, i32 %54, i8* %56)
br label %76
58: ; preds = %45
%59 = getelementptr inbounds i8*, i8** %1, i64 3
%60 = load i8*, i8** %59
%61 = tail call i32 @strtol(i8* nocapture %60, i32* null, i32 0)
%62 = getelementptr inbounds i8*, i8** %1, i64 4
%63 = load i8*, i8** %62
%64 = tail call i32 @strtol(i8* nocapture %63, i32* null, i32 0)
%65 = getelementptr inbounds i8*, i8** %1, i64 5
%66 = load i8*, i8** %65
%67 = tail call i32 @file_to_flash(i32 %40, i32 %61, i32 %64, i8* %66)
br label %76
68: ; preds = %45
%69 = getelementptr inbounds i8*, i8** %1, i64 3
%70 = load i8*, i8** %69
%71 = tail call i32 @strtol(i8* nocapture %70, i32* null, i32 0)
%72 = getelementptr inbounds i8*, i8** %1, i64 4
%73 = load i8*, i8** %72
%74 = tail call i32 @strtol(i8* nocapture %73, i32* null, i32 0)
%75 = tail call i32 @erase_flash(i32 %40, i32 %71, i32 %74)
br label %76
76: ; preds = %45, %68, %58, %48, %46
%77 = phi i32 [ 0, %45 ], [ %75, %68 ], [ %67, %58 ], [ %57, %48 ], [ 0, %46 ]
%78 = tail call i64 @close(i32 %40)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %82
82: ; preds = %80, %76
%83 = tail call i32 @exit(i32 %77)
unreachable
}