#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ closeEc(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fail(char *);
int /*<<< orphan*/ *initEc();
int /*<<< orphan*/ printf(char *, ...);
int read1(int /*<<< orphan*/ *, int, int);
int read16(int /*<<< orphan*/ *, int);
int read8(int /*<<< orphan*/ *, int);
scalar_t__ round(double);
char *strchr(char *, char);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ write1(int /*<<< orphan*/ *, unsigned char, unsigned char,
                          unsigned char);
int /*<<< orphan*/ write8(int /*<<< orphan*/ *, int, int);
int main(int argc, char **args) {
  FILE *ec = initEc();
  if (!ec)
    fail("Unable to initialize embedded controller; did you forget to use "
         "sudo?");
  if (argc == 3) {
    char *dotIdx = strchr(args[1], '.');
    if (dotIdx != NULL) {
      *dotIdx = '\0';
      dotIdx++;
      unsigned char offset = (unsigned char)strtol(args[1], NULL, 0);
      unsigned char bit = (unsigned char)atoi(dotIdx);
      unsigned char value = (unsigned char)strtol(args[2], NULL, 0);
      write1(ec, offset, bit, value);
    } else {
      unsigned char offset = (unsigned char)strtol(args[1], NULL, 0);
      unsigned char value = (unsigned char)strtol(args[2], NULL, 0);
      write8(ec, offset, value);
    }
  } else {
    write8(ec, 0x01, 0xA3);
    printf("Usage: sudo %s [<hex-offset[.bit]> <hex-value>]\n", args[0]);
    printf("   Ex: sudo %s 0x01.6 0x07\n\n", args[0]);
    printf("Current Embedded Controller Values:\n");
    printf("  USB Charge During Sleep     [0x01.5]: %d\n", read1(ec, 0x01, 5));
    printf("  USB Charge During Hibernate [0x07.2]: %d\n", read1(ec, 0x07, 2));
    printf("  Camera Enabled              [0x01.6]: %d\n", read1(ec, 0x01, 6));
    printf("  Bluetooth Enabled           [0x01.7]: %d\n", read1(ec, 0x01, 7));
    printf("  WiFi Enabled                [0x02.6]: %d\n", read1(ec, 0x02, 6));
    printf("  Touchpad Enabled            [0x03.5]: %d\n", read1(ec, 0x03, 5));
    printf("  Ambient Light               [0x66]:   %d%%\n", read8(ec, 0x66));
    printf("  Screen Enabled              [0x09.3]: %d\n", read1(ec, 0x09, 3));
    printf("  Keyboard Backlight Mode     [0xD7]:   %d\n", read8(ec, 0xD7));
    printf("  CPU Temp                    [0x60]:   %d C\n", read8(ec, 0x60));
    printf("  GPU Temp                    [0x61]:   %d C\n", read8(ec, 0x61));
    printf("  MLB Temp                    [0x62]:   %d C\n", read8(ec, 0x62));
    printf("  Fan0 Speed                  [0xFC]:   %d RPM\n",
           read16(ec, 0xFC));
    printf("  Fan1 Speed                  [0xFE]:   %d RPM\n",
           read16(ec, 0xFE));
    printf("  Fan Control Enabled         [0x13.3]: %d\n", read1(ec, 0x13, 3));
    printf("  Fan Quiet Mode Enabled      [0x08.6]: %d\n", read1(ec, 0x08, 6));
    printf("  Fan Gaming Mode Enabled     [0x12.4]: %d\n", read1(ec, 0x12, 4));
    printf("  Fan Custom Mode Enabled     [0x13.0]: %d\n", read1(ec, 0x13, 0));
    printf("  Fan0 Custom Speed Setting   [0xB0]:   %d%%\n",
           (int)round(read8(ec, 0xB0) / 2.55));
    printf("  Fan1 Custom Speed Setting   [0xB1]:   %d%%\n",
           (int)round(read8(ec, 0xB1) / 2.55));
    printf("  Current Speed Setting       [0x64]:   %d\n", read8(ec, 0x64));
  }
  closeEc(ec);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <initEc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1218 <main+0x38>
lea    0xdf5(%rip),%rdi
call   1040 <fail@plt>
cmpl   $0x3,-0x8(%rbp)
jne    12ee <main+0x10e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12ac <main+0xcc>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %al,-0x22(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %al,-0x23(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x21(%rbp),%cl
mov    -0x22(%rbp),%al
movzbl %cl,%esi
movzbl %al,%edx
movzbl -0x23(%rbp),%ecx
call   1050 <write1@plt>
jmp    12e9 <main+0x109>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %al,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %al,-0x25(%rbp)
mov    -0x18(%rbp),%rdi
movzbl -0x24(%rbp),%esi
movzbl -0x25(%rbp),%edx
call   10b0 <write8@plt>
jmp    160d <main+0x42d>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0xa3,%edx
call   10b0 <write8@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x7,%esi
mov    $0x2,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
mov    $0x7,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
mov    $0x6,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
mov    $0x5,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x66,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x9,%esi
mov    $0x3,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xd7,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x60,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x61,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x62,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xfc,%esi
call   1090 <read16@plt>
mov    %eax,%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xfe,%esi
call   1090 <read16@plt>
mov    %eax,%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x13,%esi
mov    $0x3,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x8,%esi
mov    $0x6,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x12,%esi
mov    $0x4,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x13,%esi
xor    %edx,%edx
call   10c0 <read1@plt>
mov    %eax,%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xb0,%esi
call   1080 <read8@plt>
cvtsi2sd %eax,%xmm0
movsd  0xa5d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   10d0 <round@plt>
mov    %eax,%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xb1,%esi
call   1080 <read8@plt>
cvtsi2sd %eax,%xmm0
movsd  0xa2a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   10d0 <round@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x64,%esi
call   1080 <read8@plt>
mov    %eax,%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1100 <closeEc@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <initEc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1218 <main+0x28>
lea    0xdf5(%rip),%rdi
call   1050 <fail@plt>
cmp    $0x3,%ebx
jne    1266 <main+0x76>
mov    0x8(%r15),%r12
mov    %r12,%rdi
mov    $0x2e,%esi
call   1070 <strchr@plt>
test   %rax,%rax
jne    1562 <main+0x372>
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %rax,%rbx
mov    0x10(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
movzbl %bl,%esi
movzbl %al,%edx
mov    %r14,%rdi
call   10c0 <write8@plt>
jmp    15a6 <main+0x3b6>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0xa3,%edx
call   10c0 <write8@plt>
mov    (%r15),%rsi
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%r15),%rsi
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x11ab(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   10d0 <read1@plt>
lea    0xddd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x2,%edx
call   10d0 <read1@plt>
lea    0xde7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   10d0 <read1@plt>
lea    0xdf1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x7,%edx
call   10d0 <read1@plt>
lea    0xdfb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x6,%edx
call   10d0 <read1@plt>
lea    0xe05(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
call   10d0 <read1@plt>
lea    0xe0f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x66,%esi
call   1090 <read8@plt>
lea    0xe1e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    $0x3,%edx
call   10d0 <read1@plt>
lea    0xe2a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0xd7,%esi
call   1090 <read8@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x60,%esi
call   1090 <read8@plt>
lea    0xe48(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x61,%esi
call   1090 <read8@plt>
lea    0xe59(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x62,%esi
call   1090 <read8@plt>
lea    0xe6a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0xfc,%esi
call   10a0 <read16@plt>
lea    0xe7b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0xfe,%esi
call   10a0 <read16@plt>
lea    0xe8e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x13,%esi
mov    $0x3,%edx
call   10d0 <read1@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x6,%edx
call   10d0 <read1@plt>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x12,%esi
mov    $0x4,%edx
call   10d0 <read1@plt>
lea    0xeb0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x13,%esi
xor    %edx,%edx
call   10d0 <read1@plt>
lea    0xebd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0xb0,%esi
call   1090 <read8@plt>
cvtsi2sd %eax,%xmm0
divsd  0xb03(%rip),%xmm0
call   10e0 <round@plt>
lea    0xebb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0xb1,%esi
call   1090 <read8@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xad2(%rip),%xmm0
call   10e0 <round@plt>
lea    0xeb8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
mov    $0x64,%esi
call   1090 <read8@plt>
lea    0xec9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    15a6 <main+0x3b6>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
mov    0x8(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   10f0 <atoi@plt>
mov    %rax,%rbx
mov    0x10(%r15),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtol@plt>
movzbl %r12b,%esi
movzbl %al,%ecx
movzbl %bl,%edx
mov    %r14,%rdi
call   1060 <write1@plt>
mov    %r14,%rdi
call   1110 <closeEc@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [70 x i8] c"Unable to initialize embedded controller; did you forget to use sudo?\00"
@.str.1 = [49 x i8] c"Usage: sudo %s [<hex-offset[.bit]> <hex-value>]\0A\00"
@.str.2 = [29 x i8] c" Ex: sudo %s 0x01.6 0x07\0A\0A\00"
@.str.3 = [37 x i8] c"Current Embedded Controller Values:\0A\00"
@.str.4 = [44 x i8] c" USB Charge During Sleep [0x01.5]: %d\0A\00"
@.str.5 = [44 x i8] c" USB Charge During Hibernate [0x07.2]: %d\0A\00"
@.str.6 = [44 x i8] c" Camera Enabled [0x01.6]: %d\0A\00"
@.str.7 = [44 x i8] c" Bluetooth Enabled [0x01.7]: %d\0A\00"
@.str.8 = [44 x i8] c" WiFi Enabled [0x02.6]: %d\0A\00"
@.str.9 = [44 x i8] c" Touchpad Enabled [0x03.5]: %d\0A\00"
@.str.10 = [46 x i8] c" Ambient Light [0x66]: %d%%\0A\00"
@.str.11 = [44 x i8] c" Screen Enabled [0x09.3]: %d\0A\00"
@.str.12 = [44 x i8] c" Keyboard Backlight Mode [0xD7]: %d\0A\00"
@.str.13 = [46 x i8] c" CPU Temp [0x60]: %d C\0A\00"
@.str.14 = [46 x i8] c" GPU Temp [0x61]: %d C\0A\00"
@.str.15 = [46 x i8] c" MLB Temp [0x62]: %d C\0A\00"
@.str.16 = [48 x i8] c" Fan0 Speed [0xFC]: %d RPM\0A\00"
@.str.17 = [48 x i8] c" Fan1 Speed [0xFE]: %d RPM\0A\00"
@.str.18 = [44 x i8] c" Fan Control Enabled [0x13.3]: %d\0A\00"
@.str.19 = [44 x i8] c" Fan Quiet Mode Enabled [0x08.6]: %d\0A\00"
@.str.20 = [44 x i8] c" Fan Gaming Mode Enabled [0x12.4]: %d\0A\00"
@.str.21 = [44 x i8] c" Fan Custom Mode Enabled [0x13.0]: %d\0A\00"
@.str.22 = [46 x i8] c" Fan0 Custom Speed Setting [0xB0]: %d%%\0A\00"
@.str.23 = [46 x i8] c" Fan1 Custom Speed Setting [0xB1]: %d%%\0A\00"
@.str.24 = [44 x i8] c" Current Speed Setting [0x64]: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32* (...) @initEc()
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp ne i32* %14, null
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 @fail(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %68
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i8* @strchr(i8* %24, i8 signext 46)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %50
28: ; preds = %21
%29 = load i8*, i8** %7
store i8 0, i8* %29
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strtol(i8* %34, i32* null, i32 0)
%36 = trunc i64 %35 to i8
store i8 %36, i8* %8
%37 = load i8*, i8** %7
%38 = call i64 @atoi(i8* %37)
%39 = trunc i64 %38 to i8
store i8 %39, i8* %9
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i64 @strtol(i8* %42, i32* null, i32 0)
%44 = trunc i64 %43 to i8
store i8 %44, i8* %10
%45 = load i32*, i32** %6
%46 = load i8, i8* %8
%47 = load i8, i8* %9
%48 = load i8, i8* %10
%49 = call i32 @write1(i32* %45, i8 zeroext %46, i8 zeroext %47, i8 zeroext %48)
br label %67
50: ; preds = %21
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @strtol(i8* %53, i32* null, i32 0)
%55 = trunc i64 %54 to i8
store i8 %55, i8* %11
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
%59 = call i64 @strtol(i8* %58, i32* null, i32 0)
%60 = trunc i64 %59 to i8
store i8 %60, i8* %12
%61 = load i32*, i32** %6
%62 = load i8, i8* %11
%63 = zext i8 %62 to i32
%64 = load i8, i8* %12
%65 = zext i8 %64 to i32
%66 = call i32 @write8(i32* %61, i32 %63, i32 %65)
br label %67
67: ; preds = %50, %28
br label %151
68: ; preds = %18
%69 = load i32*, i32** %6
%70 = call i32 @write8(i32* %69, i32 1, i32 163)
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %73)
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 0
%77 = load i8*, i8** %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%80 = load i32*, i32** %6
%81 = call i32 @read1(i32* %80, i32 1, i32 5)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %81)
%83 = load i32*, i32** %6
%84 = call i32 @read1(i32* %83, i32 7, i32 2)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %84)
%86 = load i32*, i32** %6
%87 = call i32 @read1(i32* %86, i32 1, i32 6)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %87)
%89 = load i32*, i32** %6
%90 = call i32 @read1(i32* %89, i32 1, i32 7)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i32 %90)
%92 = load i32*, i32** %6
%93 = call i32 @read1(i32* %92, i32 2, i32 6)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %93)
%95 = load i32*, i32** %6
%96 = call i32 @read1(i32* %95, i32 3, i32 5)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i32 %96)
%98 = load i32*, i32** %6
%99 = call i32 @read8(i32* %98, i32 102)
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %99)
%101 = load i32*, i32** %6
%102 = call i32 @read1(i32* %101, i32 9, i32 3)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i32 %102)
%104 = load i32*, i32** %6
%105 = call i32 @read8(i32* %104, i32 215)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %105)
%107 = load i32*, i32** %6
%108 = call i32 @read8(i32* %107, i32 96)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0), i32 %108)
%110 = load i32*, i32** %6
%111 = call i32 @read8(i32* %110, i32 97)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %111)
%113 = load i32*, i32** %6
%114 = call i32 @read8(i32* %113, i32 98)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.15, i64 0, i64 0), i32 %114)
%116 = load i32*, i32** %6
%117 = call i32 @read16(i32* %116, i32 252)
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.16, i64 0, i64 0), i32 %117)
%119 = load i32*, i32** %6
%120 = call i32 @read16(i32* %119, i32 254)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.17, i64 0, i64 0), i32 %120)
%122 = load i32*, i32** %6
%123 = call i32 @read1(i32* %122, i32 19, i32 3)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i32 %123)
%125 = load i32*, i32** %6
%126 = call i32 @read1(i32* %125, i32 8, i32 6)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0), i32 %126)
%128 = load i32*, i32** %6
%129 = call i32 @read1(i32* %128, i32 18, i32 4)
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i32 %129)
%131 = load i32*, i32** %6
%132 = call i32 @read1(i32* %131, i32 19, i32 0)
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.21, i64 0, i64 0), i32 %132)
%134 = load i32*, i32** %6
%135 = call i32 @read8(i32* %134, i32 176)
%136 = sitofp i32 %135 to double
%137 = fdiv double %136, 2.550000e+00
%138 = call i64 @round(double %137)
%139 = trunc i64 %138 to i32
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0), i32 %139)
%141 = load i32*, i32** %6
%142 = call i32 @read8(i32* %141, i32 177)
%143 = sitofp i32 %142 to double
%144 = fdiv double %143, 2.550000e+00
%145 = call i64 @round(double %144)
%146 = trunc i64 %145 to i32
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0), i32 %146)
%148 = load i32*, i32** %6
%149 = call i32 @read8(i32* %148, i32 100)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.24, i64 0, i64 0), i32 %149)
br label %151
151: ; preds = %68, %67
%152 = load i32*, i32** %6
%153 = call i32 @closeEc(i32* %152)
%154 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [70 x i8] c"Unable to initialize embedded controller; did you forget to use sudo?\00"
@.str.1 = [49 x i8] c"Usage: sudo %s [<hex-offset[.bit]> <hex-value>]\0A\00"
@.str.2 = [29 x i8] c" Ex: sudo %s 0x01.6 0x07\0A\0A\00"
@.str.4 = [44 x i8] c" USB Charge During Sleep [0x01.5]: %d\0A\00"
@.str.5 = [44 x i8] c" USB Charge During Hibernate [0x07.2]: %d\0A\00"
@.str.6 = [44 x i8] c" Camera Enabled [0x01.6]: %d\0A\00"
@.str.7 = [44 x i8] c" Bluetooth Enabled [0x01.7]: %d\0A\00"
@.str.8 = [44 x i8] c" WiFi Enabled [0x02.6]: %d\0A\00"
@.str.9 = [44 x i8] c" Touchpad Enabled [0x03.5]: %d\0A\00"
@.str.10 = [46 x i8] c" Ambient Light [0x66]: %d%%\0A\00"
@.str.11 = [44 x i8] c" Screen Enabled [0x09.3]: %d\0A\00"
@.str.12 = [44 x i8] c" Keyboard Backlight Mode [0xD7]: %d\0A\00"
@.str.13 = [46 x i8] c" CPU Temp [0x60]: %d C\0A\00"
@.str.14 = [46 x i8] c" GPU Temp [0x61]: %d C\0A\00"
@.str.15 = [46 x i8] c" MLB Temp [0x62]: %d C\0A\00"
@.str.16 = [48 x i8] c" Fan0 Speed [0xFC]: %d RPM\0A\00"
@.str.17 = [48 x i8] c" Fan1 Speed [0xFE]: %d RPM\0A\00"
@.str.18 = [44 x i8] c" Fan Control Enabled [0x13.3]: %d\0A\00"
@.str.19 = [44 x i8] c" Fan Quiet Mode Enabled [0x08.6]: %d\0A\00"
@.str.20 = [44 x i8] c" Fan Gaming Mode Enabled [0x12.4]: %d\0A\00"
@.str.21 = [44 x i8] c" Fan Custom Mode Enabled [0x13.0]: %d\0A\00"
@.str.22 = [46 x i8] c" Fan0 Custom Speed Setting [0xB0]: %d%%\0A\00"
@.str.23 = [46 x i8] c" Fan1 Custom Speed Setting [0xB1]: %d%%\0A\00"
@.str.24 = [44 x i8] c" Current Speed Setting [0x64]: %d\0A\00"
@str = [36 x i8] c"Current Embedded Controller Values:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32* (...) @initEc()
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fail(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %36
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i8* @strchr(i8* dereferenceable(1) %11, i8 signext 46)
%13 = icmp eq i8* %12, null
br i1 %13, label %26, label %14
14: ; preds = %9
store i8 0, i8* %12
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = load i8*, i8** %10
%17 = tail call i64 @strtol(i8* nocapture %16, i32* null, i32 0)
%18 = trunc i64 %17 to i8
%19 = tail call i64 @atoi(i8* %15)
%20 = trunc i64 %19 to i8
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i64 @strtol(i8* nocapture %22, i32* null, i32 0)
%24 = trunc i64 %23 to i8
%25 = tail call i32 @write1(i32* %3, i8 zeroext %18, i8 zeroext %20, i8 zeroext %24)
br label %93
26: ; preds = %9
%27 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 0)
%28 = trunc i64 %27 to i32
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = tail call i64 @strtol(i8* nocapture %30, i32* null, i32 0)
%32 = trunc i64 %31 to i32
%33 = and i32 %28, 255
%34 = and i32 %32, 255
%35 = tail call i32 @write8(i32* %3, i32 %33, i32 %34)
br label %93
36: ; preds = %7
%37 = tail call i32 @write8(i32* %3, i32 1, i32 163)
%38 = load i8*, i8** %1
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %1
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%43 = tail call i32 @read1(i32* %3, i32 1, i32 5)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = tail call i32 @read1(i32* %3, i32 7, i32 2)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = tail call i32 @read1(i32* %3, i32 1, i32 6)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = tail call i32 @read1(i32* %3, i32 1, i32 7)
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%51 = tail call i32 @read1(i32* %3, i32 2, i32 6)
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %51)
%53 = tail call i32 @read1(i32* %3, i32 3, i32 5)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i32 %53)
%55 = tail call i32 @read8(i32* %3, i32 102)
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %55)
%57 = tail call i32 @read1(i32* %3, i32 9, i32 3)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i32 %57)
%59 = tail call i32 @read8(i32* %3, i32 215)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %59)
%61 = tail call i32 @read8(i32* %3, i32 96)
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0), i32 %61)
%63 = tail call i32 @read8(i32* %3, i32 97)
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i32 %63)
%65 = tail call i32 @read8(i32* %3, i32 98)
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.15, i64 0, i64 0), i32 %65)
%67 = tail call i32 @read16(i32* %3, i32 252)
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.16, i64 0, i64 0), i32 %67)
%69 = tail call i32 @read16(i32* %3, i32 254)
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.17, i64 0, i64 0), i32 %69)
%71 = tail call i32 @read1(i32* %3, i32 19, i32 3)
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i32 %71)
%73 = tail call i32 @read1(i32* %3, i32 8, i32 6)
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0), i32 %73)
%75 = tail call i32 @read1(i32* %3, i32 18, i32 4)
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i32 %75)
%77 = tail call i32 @read1(i32* %3, i32 19, i32 0)
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.21, i64 0, i64 0), i32 %77)
%79 = tail call i32 @read8(i32* %3, i32 176)
%80 = sitofp i32 %79 to double
%81 = fdiv double %80, 2.550000e+00
%82 = tail call i64 @round(double %81)
%83 = trunc i64 %82 to i32
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0), i32 %83)
%85 = tail call i32 @read8(i32* %3, i32 177)
%86 = sitofp i32 %85 to double
%87 = fdiv double %86, 2.550000e+00
%88 = tail call i64 @round(double %87)
%89 = trunc i64 %88 to i32
%90 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0), i32 %89)
%91 = tail call i32 @read8(i32* %3, i32 100)
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.24, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %14, %26, %36
%94 = tail call i32 @closeEc(i32* %3)
%95 = tail call i32 @exit(i32 0)
unreachable
}