#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 */
scalar_t__ EBUSY;
int MS_NOATIME;
int MS_NODEV;
int MS_NODIRATIME;
int O_CREAT;
int O_EXCL;
int O_WRONLY;
int atoi(char *);
char *calloc(int, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int mount(char *, char *, char *, int, char *);
int open(char *, int, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *strstr(char *, char *);
scalar_t__ umount(char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int cmdfd, ffd;
  int ret = 0;
  char *msg = calloc(80, 1);
  char *s = strstr(argv[3], "dkp-vmin-");
  char *e = NULL;
  int vmin_i;
  int do_umount = 1;
  if (argc != 4)
    return 1;
  cmdfd = atoi(argv[2]);
  if (s) {
    s += strlen("dkp-vmin-");
    for (e = s; *e >= '0' && *e <= '9'; e++)
      ;
    if (*e == '.')
      *e = 0;
    else
      e = NULL;
  }
  if (!e) {
    write(cmdfd,
          "ui_print "
          "Rename me to something like \"dkp-vmin-700.zip\"!"
          "\nui_print\n",
          strlen("ui_print "
                 "Rename me to something like \"dkp-vmin-700.zip\"!"
                 "\nui_print\n"));
    return 2;
  }
  vmin_i = atoi(s);
  if (vmin_i > 1500) {
    write(cmdfd,
          "ui_print "
          "Explosion mode engaged."
          "\nui_print\n",
          strlen("ui_print "
                 "Explosion mode engaged."
                 "\nui_print\n"));
    write(cmdfd,
          "ui_print "
          "Have a nice day."
          "\nui_print\n",
          strlen("ui_print "
                 "Have a nice day."
                 "\nui_print\n"));
    return 2;
  }
  if (vmin_i > 1150 || vmin_i < 600) {
    strncat(msg, "ui_print ", 80);
    strncat(msg, s, 80);
    strncat(msg, " mV?  That seems excessive.\nui_print\n", 80);
    write(cmdfd, msg, strlen(msg));
    write(cmdfd,
          "ui_print "
          "600 to 1150 mV would be reasonable"
          "\nui_print\n",
          strlen("ui_print "
                 "600 to 1150 mV would be reasonable"
                 "\nui_print\n"));
    return 2;
  }
  if (ret = mount("/dev/block/mmcblk0p14", "/system", "ext4",
                  MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
    write(cmdfd,
          "ui_print "
          "Can't mount /system!"
          "\nui_print\n",
          strlen("ui_print "
                 "Can't mount /system!"
                 "\nui_print\n"));
    if (errno != EBUSY)
      return errno;
    do_umount = 0;
  }
  write(cmdfd,
        "ui_print "
        "Adjusting minimum voltage..."
        "\nui_print\n",
        strlen("ui_print "
               "Adjusting minimum voltage..."
               "\nui_print\n"));
  unlink("/system/etc/init.d/00dkp-vmin");
  ffd =
      open("/system/etc/init.d/00dkp-vmin", O_WRONLY | O_CREAT | O_EXCL, 0755);
  if (ffd) {
    strncat(msg, "ui_print New minimum voltage is ", 80);
    strncat(msg, s, 80);
    strncat(msg, " mV.\nui_print\n", 80);
    write(cmdfd, msg, strlen(msg));
    write(ffd, "#!/system/bin/sh\necho ", strlen("#!/system/bin/sh\necho "));
    write(ffd, s, strlen(s));
    write(ffd, " >/sys/devices/system/cpu/cpufreq/dkp/vmin\n",
          strlen(" >/sys/devices/system/cpu/cpufreq/dkp/vmin\n"));
    close(ffd);
  } else {
    write(cmdfd,
          "ui_print "
          "Adjustment failed!"
          "\nui_print\n",
          strlen("ui_print "
                 "Adjustment failed!"
                 "\nui_print\n"));
    ret = 4;
  }
bail:
  if (do_umount) {
    if (umount("/system")) {
      write(cmdfd,
            "ui_print "
            "Couldn't unmount /system!"
            "\nui_print\n",
            strlen("ui_print "
                   "Couldn't unmount /system!"
                   "\nui_print\n"));
      return -ret;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x50,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe0e(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x1,-0x40(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1220 <main+0x70>
movl   $0x1,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12d3 <main+0x123>
lea    0xdbe(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x41(%rbp)
jl     1284 <main+0xd4>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1294 <main+0xe4>
jmp    12aa <main+0xfa>
jmp    1299 <main+0xe9>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    125f <main+0xaf>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    12c6 <main+0x116>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
jmp    12ce <main+0x11e>
movq   $0x0,-0x38(%rbp)
jmp    12d3 <main+0x123>
cmpq   $0x0,-0x38(%rbp)
jne    130d <main+0x15d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
lea    0xd1f(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%edx
lea    0xd0e(%rip),%rsi
call   1050 <write@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
mov    -0x30(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x5dc,-0x3c(%rbp)
jle    1378 <main+0x1c8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x50(%rbp)
lea    0xd1a(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%edx
lea    0xd09(%rip),%rsi
call   1050 <write@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    0xd22(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%edx
lea    0xd11(%rip),%rsi
call   1050 <write@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
cmpl   $0x47e,-0x3c(%rbp)
jg     1392 <main+0x1e2>
cmpl   $0x258,-0x3c(%rbp)
jge    1422 <main+0x272>
mov    -0x28(%rbp),%rdi
lea    0xcff(%rip),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x28(%rbp),%rdi
lea    0xce2(%rip),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    0xccc(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    %eax,%edx
lea    0xcbb(%rip),%rsi
call   1050 <write@plt>
movl   $0x2,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
mov    0x2bb7(%rip),%rax
mov    (%rax),%ecx
mov    0x2bb6(%rip),%rax
or     (%rax),%ecx
mov    0x2b7d(%rip),%rax
or     (%rax),%ecx
lea    0xcbe(%rip),%rdi
lea    0xccd(%rip),%rsi
lea    0xcce(%rip),%rdx
lea    0xdb4(%rip),%r8
call   1070 <mount@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     14c0 <main+0x310>
mov    -0x14(%rbp),%eax
mov    %eax,-0x68(%rbp)
lea    0xcae(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%edi
mov    %eax,%edx
lea    0xc9d(%rip),%rsi
call   1050 <write@plt>
mov    0x2b2c(%rip),%rax
mov    (%rax),%rax
mov    0x2b12(%rip),%rcx
cmp    (%rcx),%rax
je     14b9 <main+0x309>
mov    0x2b12(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
movl   $0x0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x6c(%rbp)
lea    0xc80(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    %eax,%edx
lea    0xc6f(%rip),%rsi
call   1050 <write@plt>
lea    0xc93(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2aaa(%rip),%rax
mov    (%rax),%esi
mov    0x2af9(%rip),%rax
or     (%rax),%esi
mov    0x2ac0(%rip),%rax
or     (%rax),%esi
lea    0xc6c(%rip),%rdi
mov    $0x1ed,%edx
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     160d <main+0x45d>
mov    -0x28(%rbp),%rdi
lea    0xc68(%rip),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x28(%rbp),%rdi
lea    0xc62(%rip),%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x80(%rbp)
lea    0xc29(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x80(%rbp),%edi
mov    %eax,%edx
lea    0xc18(%rip),%rsi
call   1050 <write@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x70(%rbp)
lea    0xbf8(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x70(%rbp),%edi
mov    %eax,%edx
lea    0xbe7(%rip),%rsi
call   1050 <write@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
jmp    163d <main+0x48d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x90(%rbp)
lea    0xbf1(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x90(%rbp),%edi
mov    %eax,%edx
lea    0xbdd(%rip),%rsi
call   1050 <write@plt>
movl   $0x4,-0x1c(%rbp)
jmp    1642 <main+0x492>
cmpl   $0x0,-0x40(%rbp)
je     169d <main+0x4ed>
lea    0xac5(%rip),%rdi
call   1040 <umount@plt>
cmp    $0x0,%rax
je     1698 <main+0x4e8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x94(%rbp)
lea    0xbc2(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x94(%rbp),%edi
mov    %eax,%edx
lea    0xbae(%rip),%rsi
call   1050 <write@plt>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16a3 <main+0x4f3>
jmp    169d <main+0x4ed>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x1,%r15d
mov    $0x50,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r12
mov    0x18(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x4,%ebx
jne    128e <main+0xde>
mov    %rax,%r13
mov    0x10(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
test   %r13,%r13
je     126c <main+0xbc>
lea    0xdf4(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%r13
mov    %r13,%rax
nopl   0x0(%rax)
movzbl (%rax),%ecx
lea    -0x30(%rcx),%edx
add    $0x1,%rax
cmp    $0xa,%dl
jb     1220 <main+0x70>
cmp    $0x2e,%cl
jne    126c <main+0xbc>
movb   $0x0,-0x1(%rax)
mov    %r13,%rdi
call   10c0 <atoi@plt>
cmp    $0x5dd,%eax
jl     12a0 <main+0xf0>
lea    0xdff(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xe0e(%rip),%rbx
jmp    1273 <main+0xc3>
lea    0xd97(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    $0x2,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xfffffb81,%eax
cmp    $0xfffffdd8,%eax
ja     1305 <main+0x155>
lea    0xde9(%rip),%rsi
mov    %r12,%rdi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
lea    0xdcf(%rip),%rsi
mov    %r12,%rdi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xdcc(%rip),%rbx
jmp    1273 <main+0xc3>
mov    0x2cd4(%rip),%rax
mov    0x2cd5(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2c9a(%rip),%rax
or     (%rax),%ecx
lea    0xddb(%rip),%rdi
lea    0xdea(%rip),%rsi
lea    0xdeb(%rip),%rdx
lea    0xed1(%rip),%r8
call   1070 <mount@plt>
mov    %eax,%ebp
test   %eax,%eax
je     137d <main+0x1cd>
lea    0xdd7(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%r15
mov    0x2c3c(%rip),%rax
cmp    (%rax),%r15
jne    128e <main+0xde>
lea    0xdc9(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xddd(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2bf1(%rip),%rax
mov    0x2c42(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2c07(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x1ed,%edx
call   10b0 <open@plt>
test   %eax,%eax
je     1480 <main+0x2d0>
mov    %eax,%ebx
lea    0xdba(%rip),%rsi
mov    %r12,%rdi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x50,%edx
call   1080 <strncat@plt>
lea    0xdb7(%rip),%rsi
mov    %r12,%rdi
mov    $0x50,%edx
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %ebp,%r15d
lea    0xd9a(%rip),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xd82(%rip),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15d,%ebp
mov    %eax,%edx
call   1050 <write@plt>
mov    %ebx,%edi
call   1090 <close@plt>
jmp    14a2 <main+0x2f2>
lea    0xd87(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    $0x4,%r15d
test   %ebp,%ebp
jne    128e <main+0xde>
lea    0xc67(%rip),%rdi
call   1040 <umount@plt>
test   %rax,%rax
je     128e <main+0xde>
lea    0xd6e(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
neg    %r15d
jmp    128e <main+0xde>

LLVM IR (-O0):
@.str = [10 x i8] c"dkp-vmin-\00"
@.str.1 = [67 x i8] c"ui_print Rename me to something like \22dkp-vmin-700.zip\22!\0Aui_print\0A\00"
@.str.2 = [43 x i8] c"ui_print Explosion mode engaged.\0Aui_print\0A\00"
@.str.3 = [36 x i8] c"ui_print Have a nice day.\0Aui_print\0A\00"
@.str.4 = [10 x i8] c"ui_print \00"
@.str.5 = [38 x i8] c" mV? That seems excessive.\0Aui_print\0A\00"
@.str.6 = [54 x i8] c"ui_print 600 to 1150 mV would be reasonable\0Aui_print\0A\00"
@.str.7 = [22 x i8] c"/dev/block/mmcblk0p14\00"
@.str.8 = [8 x i8] c"/system\00"
@.str.9 = [5 x i8] c"ext4\00"
@MS_NOATIME = global i32 0
@MS_NODEV = global i32 0
@MS_NODIRATIME = global i32 0
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [40 x i8] c"ui_print Can't mount /system!\0Aui_print\0A\00"
@errno = global i64 0
@EBUSY = global i64 0
@.str.12 = [48 x i8] c"ui_print Adjusting minimum voltage...\0Aui_print\0A\00"
@.str.13 = [30 x i8] c"/system/etc/init.d/00dkp-vmin\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@.str.14 = [33 x i8] c"ui_print New minimum voltage is \00"
@.str.15 = [15 x i8] c" mV.\0Aui_print\0A\00"
@.str.16 = [23 x i8] c"#!/system/bin/sh\0Aecho \00"
@.str.17 = [44 x i8] c" >/sys/devices/system/cpu/cpufreq/dkp/vmin\0A\00"
@.str.18 = [38 x i8] c"ui_print Adjustment failed!\0Aui_print\0A\00"
@.str.19 = [45 x i8] c"ui_print Couldn't unmount /system!\0Aui_print\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 i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%14 = call i8* @calloc(i32 80, i32 1)
store i8* %14, i8** %9
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 3
%17 = load i8*, i8** %16
%18 = call i8* @strstr(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %10
store i8* null, i8** %11
store i32 1, i32* %13
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 4
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 1, i32* %3
br label %179
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %6
%27 = load i8*, i8** %10
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %60
29: ; preds = %22
%30 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%31 = load i8*, i8** %10
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8* %33, i8** %10
%34 = load i8*, i8** %10
store i8* %34, i8** %11
br label %35
35: ; preds = %48, %29
%36 = load i8*, i8** %11
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 48
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i8*, i8** %11
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp sle i32 %43, 57
br label %45
45: ; preds = %40, %35
%46 = phi i1 [ false, %35 ], [ %44, %40 ]
br i1 %46, label %47, label %51
47: ; preds = %45
br label %48
48: ; preds = %47
%49 = load i8*, i8** %11
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %11
br label %35
51: ; preds = %45
%52 = load i8*, i8** %11
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 46
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = load i8*, i8** %11
store i8 0, i8* %57
br label %59
58: ; preds = %51
store i8* null, i8** %11
br label %59
59: ; preds = %58, %56
br label %60
60: ; preds = %59, %22
%61 = load i8*, i8** %11
%62 = icmp ne i8* %61, null
br i1 %62, label %67, label %63
63: ; preds = %60
%64 = load i32, i32* %6
%65 = call i32 @strlen(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%66 = call i32 @write(i32 %64, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i32 %65)
store i32 2, i32* %3
br label %179
67: ; preds = %60
%68 = load i8*, i8** %10
%69 = call i32 @atoi(i8* %68)
store i32 %69, i32* %12
%70 = load i32, i32* %12
%71 = icmp sgt i32 %70, 1500
br i1 %71, label %72, label %79
72: ; preds = %67
%73 = load i32, i32* %6
%74 = call i32 @strlen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%75 = call i32 @write(i32 %73, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %6
%77 = call i32 @strlen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%78 = call i32 @write(i32 %76, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %77)
store i32 2, i32* %3
br label %179
79: ; preds = %67
%80 = load i32, i32* %12
%81 = icmp sgt i32 %80, 1150
br i1 %81, label %85, label %82
82: ; preds = %79
%83 = load i32, i32* %12
%84 = icmp slt i32 %83, 600
br i1 %84, label %85, label %101
85: ; preds = %82, %79
%86 = load i8*, i8** %9
%87 = call i32 @strncat(i8* %86, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 80)
%88 = load i8*, i8** %9
%89 = load i8*, i8** %10
%90 = call i32 @strncat(i8* %88, i8* %89, i32 80)
%91 = load i8*, i8** %9
%92 = call i32 @strncat(i8* %91, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 80)
%93 = load i32, i32* %6
%94 = load i8*, i8** %9
%95 = load i8*, i8** %9
%96 = call i32 @strlen(i8* %95)
%97 = call i32 @write(i32 %93, i8* %94, i32 %96)
%98 = load i32, i32* %6
%99 = call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%100 = call i32 @write(i32 %98, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %99)
store i32 2, i32* %3
br label %179
101: ; preds = %82
%102 = load i32, i32* @MS_NOATIME
%103 = load i32, i32* @MS_NODEV
%104 = or i32 %102, %103
%105 = load i32, i32* @MS_NODIRATIME
%106 = or i32 %104, %105
%107 = call i32 @mount(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), 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), i32 %106, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
store i32 %107, i32* %8
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %120
109: ; preds = %101
%110 = load i32, i32* %6
%111 = call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%112 = call i32 @write(i32 %110, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i32 %111)
%113 = load i64, i64* @errno
%114 = load i64, i64* @EBUSY
%115 = icmp ne i64 %113, %114
br i1 %115, label %116, label %119
116: ; preds = %109
%117 = load i64, i64* @errno
%118 = trunc i64 %117 to i32
store i32 %118, i32* %3
br label %179
119: ; preds = %109
store i32 0, i32* %13
br label %120
120: ; preds = %119, %101
%121 = load i32, i32* %6
%122 = call i32 @strlen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
%123 = call i32 @write(i32 %121, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i32 %122)
%124 = call i32 @unlink(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%125 = load i32, i32* @O_WRONLY
%126 = load i32, i32* @O_CREAT
%127 = or i32 %125, %126
%128 = load i32, i32* @O_EXCL
%129 = or i32 %127, %128
%130 = call i32 @open(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i32 %129, i32 493)
store i32 %130, i32* %7
%131 = load i32, i32* %7
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %159
133: ; preds = %120
%134 = load i8*, i8** %9
%135 = call i32 @strncat(i8* %134, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i32 80)
%136 = load i8*, i8** %9
%137 = load i8*, i8** %10
%138 = call i32 @strncat(i8* %136, i8* %137, i32 80)
%139 = load i8*, i8** %9
%140 = call i32 @strncat(i8* %139, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i32 80)
%141 = load i32, i32* %6
%142 = load i8*, i8** %9
%143 = load i8*, i8** %9
%144 = call i32 @strlen(i8* %143)
%145 = call i32 @write(i32 %141, i8* %142, i32 %144)
%146 = load i32, i32* %7
%147 = call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%148 = call i32 @write(i32 %146, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i32 %147)
%149 = load i32, i32* %7
%150 = load i8*, i8** %10
%151 = load i8*, i8** %10
%152 = call i32 @strlen(i8* %151)
%153 = call i32 @write(i32 %149, i8* %150, i32 %152)
%154 = load i32, i32* %7
%155 = call i32 @strlen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0))
%156 = call i32 @write(i32 %154, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0), i32 %155)
%157 = load i32, i32* %7
%158 = call i32 @close(i32 %157)
br label %163
159: ; preds = %120
%160 = load i32, i32* %6
%161 = call i32 @strlen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
%162 = call i32 @write(i32 %160, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0), i32 %161)
store i32 4, i32* %8
br label %163
163: ; preds = %159, %133
br label %164
164: ; preds = %163
%165 = load i32, i32* %13
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %177
167: ; preds = %164
%168 = call i64 @umount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %176
170: ; preds = %167
%171 = load i32, i32* %6
%172 = call i32 @strlen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0))
%173 = call i32 @write(i32 %171, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0), i32 %172)
%174 = load i32, i32* %8
%175 = sub nsw i32 0, %174
store i32 %175, i32* %3
br label %179
176: ; preds = %167
br label %177
177: ; preds = %176, %164
%178 = load i32, i32* %8
store i32 %178, i32* %3
br label %179
179: ; preds = %177, %170, %116, %85, %72, %63, %21
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@.str = [10 x i8] c"dkp-vmin-\00"
@.str.1 = [67 x i8] c"ui_print Rename me to something like \22dkp-vmin-700.zip\22!\0Aui_print\0A\00"
@.str.2 = [43 x i8] c"ui_print Explosion mode engaged.\0Aui_print\0A\00"
@.str.3 = [36 x i8] c"ui_print Have a nice day.\0Aui_print\0A\00"
@.str.4 = [10 x i8] c"ui_print \00"
@.str.5 = [38 x i8] c" mV? That seems excessive.\0Aui_print\0A\00"
@.str.6 = [54 x i8] c"ui_print 600 to 1150 mV would be reasonable\0Aui_print\0A\00"
@.str.7 = [22 x i8] c"/dev/block/mmcblk0p14\00"
@.str.8 = [8 x i8] c"/system\00"
@.str.9 = [5 x i8] c"ext4\00"
@MS_NOATIME = global i32 0
@MS_NODEV = global i32 0
@MS_NODIRATIME = global i32 0
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [40 x i8] c"ui_print Can't mount /system!\0Aui_print\0A\00"
@errno = global i64 0
@EBUSY = global i64 0
@.str.12 = [48 x i8] c"ui_print Adjusting minimum voltage...\0Aui_print\0A\00"
@.str.13 = [30 x i8] c"/system/etc/init.d/00dkp-vmin\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@.str.14 = [33 x i8] c"ui_print New minimum voltage is \00"
@.str.15 = [15 x i8] c" mV.\0Aui_print\0A\00"
@.str.16 = [23 x i8] c"#!/system/bin/sh\0Aecho \00"
@.str.17 = [44 x i8] c" >/sys/devices/system/cpu/cpufreq/dkp/vmin\0A\00"
@.str.18 = [38 x i8] c"ui_print Adjustment failed!\0Aui_print\0A\00"
@.str.19 = [45 x i8] c"ui_print Couldn't unmount /system!\0Aui_print\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call dereferenceable_or_null(80) i8* @calloc(i32 80, i32 1)
%4 = getelementptr inbounds i8*, i8** %1, i64 3
%5 = load i8*, i8** %4
%6 = tail call i8* @strstr(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %0, 4
br i1 %7, label %8, label %99
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp eq i8* %6, null
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %6, i64 %15
br label %17
17: ; preds = %17, %13
%18 = phi i8* [ %16, %13 ], [ %22, %17 ]
%19 = load i8, i8* %18
%20 = add i8 %19, -48
%21 = icmp ult i8 %20, 10
%22 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %21, label %17, label %23
23: ; preds = %17
%24 = icmp eq i8 %19, 46
br i1 %24, label %28, label %25
25: ; preds = %8, %23
%26 = tail call i32 @strlen(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %99
28: ; preds = %23
store i8 0, i8* %18
%29 = tail call i32 @atoi(i8* %16)
%30 = icmp sgt i32 %29, 1500
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = tail call i32 @strlen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%35 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %99
36: ; preds = %28
%37 = add i32 %29, -1151
%38 = icmp ult i32 %37, -551
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = tail call i32 @strncat(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 80)
%41 = tail call i32 @strncat(i8* %3, i8* %16, i32 80)
%42 = tail call i32 @strncat(i8* %3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 80)
%43 = tail call i32 @strlen(i8* %3)
%44 = tail call i32 @write(i32 %11, i8* %3, i32 %43)
%45 = tail call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%46 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %45)
br label %99
47: ; preds = %36
%48 = load i32, i32* @MS_NOATIME
%49 = load i32, i32* @MS_NODEV
%50 = or i32 %49, %48
%51 = load i32, i32* @MS_NODIRATIME
%52 = or i32 %50, %51
%53 = tail call i32 @mount(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), 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), i32 %52, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
br i1 %54, label %63, label %55
55: ; preds = %47
%56 = tail call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%57 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i32 %56)
%58 = load i64, i64* @errno
%59 = load i64, i64* @EBUSY
%60 = icmp eq i64 %58, %59
br i1 %60, label %63, label %61
61: ; preds = %55
%62 = trunc i64 %58 to i32
br label %99
63: ; preds = %55, %47
%64 = tail call i32 @strlen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
%65 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i32 %64)
%66 = tail call i32 @unlink(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%67 = load i32, i32* @O_WRONLY
%68 = load i32, i32* @O_CREAT
%69 = or i32 %68, %67
%70 = load i32, i32* @O_EXCL
%71 = or i32 %69, %70
%72 = tail call i32 @open(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i32 %71, i32 493)
%73 = icmp eq i32 %72, 0
br i1 %73, label %87, label %74
74: ; preds = %63
%75 = tail call i32 @strncat(i8* %3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i32 80)
%76 = tail call i32 @strncat(i8* %3, i8* %16, i32 80)
%77 = tail call i32 @strncat(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i32 80)
%78 = tail call i32 @strlen(i8* %3)
%79 = tail call i32 @write(i32 %11, i8* %3, i32 %78)
%80 = tail call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%81 = tail call i32 @write(i32 %72, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i32 %80)
%82 = tail call i32 @strlen(i8* %16)
%83 = tail call i32 @write(i32 %72, i8* %16, i32 %82)
%84 = tail call i32 @strlen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0))
%85 = tail call i32 @write(i32 %72, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0), i32 %84)
%86 = tail call i32 @close(i32 %72)
br label %90
87: ; preds = %63
%88 = tail call i32 @strlen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0))
%89 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.18, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %74, %87
%91 = phi i32 [ %53, %74 ], [ 4, %87 ]
br i1 %54, label %92, label %99
92: ; preds = %90
%93 = tail call i64 @umount(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %99, label %95
95: ; preds = %92
%96 = tail call i32 @strlen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0))
%97 = tail call i32 @write(i32 %11, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0), i32 %96)
%98 = sub nsw i32 0, %91
br label %99
99: ; preds = %90, %92, %2, %95, %61, %39, %31, %25
%100 = phi i32 [ 2, %31 ], [ 2, %39 ], [ %62, %61 ], [ %98, %95 ], [ 2, %25 ], [ 1, %2 ], [ %91, %92 ], [ %91, %90 ]
ret i32 %100
}