#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct i2c_rdwr_ioctl_data {
  int nmsgs;
  struct i2c_msg *msgs;
};
struct i2c_msg {
  int addr;
  int len;
  unsigned char *buf;
  int /*<<< orphan*/ flags;
};

/* Variables and functions */
int /*<<< orphan*/ I2C_M_RD;
int /*<<< orphan*/ I2C_RDWR;
int /*<<< orphan*/ I2C_SLAVE_FORCE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ioctl(int, int /*<<< orphan*/, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, char *);
int main(int argc, char **argv) {
  int fd;
  int argp = 1;
  int dev = 0;
  char devChar[] = "/dev/i2c-0";
  int addr = 0;
  unsigned char data_buf[64];
  int nw = 0;
  int nr = 0;
  int tmp_data = -1;
  if ((argc < 3) || (sscanf(argv[argp++], "%d", &dev) != 1) ||
      (sscanf(argv[argp], "0x%x|%X", &addr) != 1) || (addr < 0) ||
      (addr > 255) || (dev < 0) || (dev > 2)) {
    fprintf(stderr,
            "Usage:%s [dev:0-2] [addr:0x0-0xFE] [[w dat0 dat1 dat2 ...] | [r "
            "rlen]]\n",
            argv[0]);
    exit(1);
  }
  argp++;
  if (strcasecmp(argv[argp], "W") == 0) {
    argp++;
    for (; (argp < argc) && (1 == sscanf(argv[argp], "%x|%X", &tmp_data));
         argp++) {
      data_buf[nw++] = tmp_data;
    }
    if (nw == 0) {
      if (argp < argc)
        perror("! invalid argument!\n");
      else
        perror("! missing argument!\n");
      exit(1);
    }
  }
  if ((argp < argc) && (strcasecmp(argv[argp], "R") == 0)) {
    argp++;
    if ((argp < argc) && (1 == sscanf(argv[argp], "%x|%X", &tmp_data))) {
      nr = tmp_data;
    } else {
      perror("! missing argument!\n");
      exit(1);
    }
  }
  printf("dev%d, addr=0x%x, rlen=%d, wlen=%d, wdata=%d, %d, %d, %d, ...\n", dev,
         addr, nr, nw, data_buf[0], data_buf[1], data_buf[2], data_buf[3]);
  devChar[9] = dev + 0x30;
  fd = open(devChar, O_RDWR);
  if (fd < 0) {
    printf("open device i2c (%s) failed\n", devChar);
    exit(1);
  }
  if (ioctl(fd, I2C_SLAVE_FORCE, addr) < 0) {
    perror("i2c set slave address failed\n");
    close(fd);
    exit(1);
  }
  struct i2c_msg msg;
  struct i2c_rdwr_ioctl_data ioctl_data;
  msg.addr = addr;
  msg.len = nw;
  msg.buf = data_buf;
  msg.flags = 0;
  ioctl_data.nmsgs = 1;
  ioctl_data.msgs = &msg;
  if (nw != 0) {
    printf("ioctl write, return %d\n", ioctl(fd, I2C_RDWR, &ioctl_data));
  }
  sleep(1);
  if (nr != 0) {
    msg.len = nr;
    msg.flags |= I2C_M_RD;
    printf("ioctl read, return %d\n", ioctl(fd, I2C_RDWR, &ioctl_data));
  }
  int i;
  printf("i2c read data (raw) = ");
  for (i = 0; i < nr; i++) {
    printf("%X ", data_buf[i]);
  }
  printf("\n");
  printf("i2c read data (char) = ");
  for (i = 0; i < nr; i++) {
    printf("%c", data_buf[i]);
  }
  printf("\n");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0xe32(%rip),%rax
mov    %rax,-0x27(%rbp)
mov    0xe2f(%rip),%ax
mov    %ax,-0x1f(%rbp)
mov    0xe27(%rip),%al
mov    %al,-0x1d(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0xffffffff,-0x7c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     128b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde2(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    128b <main+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdc0(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    128b <main+0xeb>
cmpl   $0x0,-0x2c(%rbp)
jl     128b <main+0xeb>
cmpl   $0xff,-0x2c(%rbp)
jg     128b <main+0xeb>
cmpl   $0x0,-0x1c(%rbp)
jl     128b <main+0xeb>
cmpl   $0x2,-0x1c(%rbp)
jle    12b1 <main+0x111>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd74(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd91(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    13a0 <main+0x200>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0xad(%rbp)
jge    1327 <main+0x187>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd04(%rip),%rsi
lea    -0x7c(%rbp),%rdx
call   1080 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0xad(%rbp)
mov    -0xad(%rbp),%al
test   $0x1,%al
jne    133a <main+0x19a>
jmp    135e <main+0x1be>
mov    -0x7c(%rbp),%eax
mov    %al,%cl
mov    -0x74(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x74(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12e5 <main+0x145>
cmpl   $0x0,-0x74(%rbp)
jne    139b <main+0x1fb>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1385 <main+0x1e5>
lea    0xce5(%rip),%rdi
call   10a0 <perror@plt>
jmp    1391 <main+0x1f1>
lea    0xce9(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    13a0 <main+0x200>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1434 <main+0x294>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xccb(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1434 <main+0x294>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1419 <main+0x279>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc1a(%rip),%rsi
lea    -0x7c(%rbp),%rdx
call   1080 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1419 <main+0x279>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    142f <main+0x28f>
lea    0xc55(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1434 <main+0x294>
mov    -0x1c(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x78(%rbp),%ecx
mov    -0x74(%rbp),%r8d
movzbl -0x70(%rbp),%r9d
movzbl -0x6f(%rbp),%r11d
movzbl -0x6e(%rbp),%r10d
movzbl -0x6d(%rbp),%eax
lea    0xc31(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x1e(%rbp)
lea    -0x27(%rbp),%rdi
mov    0x2b65(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    14b3 <main+0x313>
lea    -0x27(%rbp),%rsi
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2b23(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
mov    $0x0,%al
call   1050 <ioctl@plt>
cmp    $0x0,%eax
jge    14f0 <main+0x350>
lea    0xc0f(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x94(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x1,-0xa8(%rbp)
lea    -0x98(%rbp),%rax
mov    %rax,-0xa0(%rbp)
cmpl   $0x0,-0x74(%rbp)
je     1563 <main+0x3c3>
mov    -0x14(%rbp),%edi
mov    0x2a75(%rip),%rax
mov    (%rax),%esi
lea    -0xa8(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    %eax,%esi
lea    0xbaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
cmpl   $0x0,-0x78(%rbp)
je     15bf <main+0x41f>
mov    -0x78(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    0x2a41(%rip),%rax
mov    (%rax),%eax
or     -0x88(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2a19(%rip),%rax
mov    (%rax),%esi
lea    -0xa8(%rbp),%rdx
mov    $0x0,%al
call   1050 <ioctl@plt>
mov    %eax,%esi
lea    0xb66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    1614 <main+0x474>
movslq -0xac(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%esi
lea    0xb53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    15d7 <main+0x437>
lea    0xa58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    1677 <main+0x4d7>
movslq -0xac(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%esi
lea    0xb0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    163a <main+0x49a>
lea    0x9f5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbp
movl   $0x0,0xc(%rsp)
movabs $0x6332692f7665642f,%rax
69 32 63
mov    %rax,0x10(%rsp)
movl   $0x302d63,0x17(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
cmp    $0x3,%edi
jl     1561 <main+0x3b1>
mov    %edi,%r15d
mov    0x8(%rbp),%rdi
lea    0xe01(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1561 <main+0x3b1>
mov    0x10(%rbp),%rdi
lea    0xde6(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    1561 <main+0x3b1>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1561 <main+0x3b1>
cmp    $0xff,%eax
jg     1561 <main+0x3b1>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1561 <main+0x3b1>
cmp    $0x3,%eax
jge    1561 <main+0x3b1>
mov    0x18(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1040 <strcasecmp@plt>
xor    %r12d,%r12d
mov    $0x3,%ebx
mov    $0x0,%r14d
test   %rax,%rax
je     1298 <main+0xe8>
cmp    %r15d,%ebx
jl     1322 <main+0x172>
jmp    136c <main+0x1bc>
lea    0xdd6(%rip),%rax
mov    %rax,0x20(%rsp)
cmp    $0x5,%r15d
jb     15d4 <main+0x424>
lea    -0x4(%r15),%r14d
xor    %r13d,%r13d
lea    0xd54(%rip),%rbx
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rbp,%r13,8),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    130a <main+0x15a>
movzbl 0x8(%rsp),%eax
mov    %al,0x50(%rsp,%r13,1)
add    $0x1,%r13
cmp    %r13,%r14
jne    12d0 <main+0x120>
test   %r14d,%r14d
je     15d4 <main+0x424>
add    $0x4,%r13
mov    %r13d,%ebx
jmp    131a <main+0x16a>
test   %r13d,%r13d
je     15c8 <main+0x418>
lea    0x4(%r13),%rbx
mov    %r13d,%r14d
xor    %r12d,%r12d
cmp    %r15d,%ebx
jge    136c <main+0x1bc>
mov    %ebx,%eax
mov    0x0(%rbp,%rax,8),%rdi
lea    0xd5a(%rip),%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    136c <main+0x1bc>
add    $0x1,%ebx
cmp    %r15d,%ebx
jge    15bf <main+0x40f>
mov    %ebx,%eax
mov    0x0(%rbp,%rax,8),%rdi
lea    0xcbc(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    15bf <main+0x40f>
mov    0x8(%rsp),%r12d
mov    0xc(%rsp),%esi
mov    0x4(%rsp),%edx
movzbl 0x50(%rsp),%r9d
movzbl 0x51(%rsp),%r10d
movzbl 0x52(%rsp),%ebx
movzbl 0x53(%rsp),%ebp
sub    $0x8,%rsp
lea    0xcf7(%rip),%rdi
mov    %r12d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
push   %rbp
push   %rbx
push   %r10
call   1050 <printf@plt>
add    $0x20,%rsp
mov    0xc(%rsp),%al
add    $0x30,%al
mov    %al,0x19(%rsp)
mov    0x2c2d(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     1584 <main+0x3d4>
mov    %eax,%r15d
mov    0x2c07(%rip),%rax
mov    (%rax),%esi
mov    0x4(%rsp),%edx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
test   %eax,%eax
js     15a1 <main+0x3f1>
mov    0x4(%rsp),%eax
mov    %eax,0x28(%rsp)
mov    %r14d,0x2c(%rsp)
lea    0x50(%rsp),%rax
mov    %rax,0x30(%rsp)
movl   $0x0,0x38(%rsp)
movl   $0x1,0x40(%rsp)
lea    0x28(%rsp),%rax
mov    %rax,0x48(%rsp)
test   %r14d,%r14d
je     144f <main+0x29f>
mov    0x2b8a(%rip),%rax
mov    (%rax),%esi
lea    0x40(%rsp),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
lea    0xcc0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
test   %r12d,%r12d
je     1515 <main+0x365>
mov    %r12d,0x2c(%rsp)
mov    0x2b5a(%rip),%rax
mov    (%rax),%eax
or     %eax,0x38(%rsp)
mov    0x2b3d(%rip),%rax
mov    (%rax),%esi
lea    0x40(%rsp),%rdx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <ioctl@plt>
lea    0xc8b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12d,%r12d
jle    1523 <main+0x373>
mov    %r12d,%ebp
lea    0xc93(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x50(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    14c0 <main+0x310>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12d,%r12d
jle    153b <main+0x38b>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl 0x50(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1500 <main+0x350>
jmp    153b <main+0x38b>
lea    0xc19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a68(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xaa1(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xb40(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xb40(%rip),%rdi
call   10b0 <perror@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xaaf(%rip),%rdi
jmp    15d9 <main+0x429>
lea    0xa91(%rip),%rax
mov    %rax,0x20(%rsp)
mov    0x20(%rsp),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.i2c_msg = type { i32, i32, i8*, i32 }
%struct.i2c_rdwr_ioctl_data = type { i32, %struct.i2c_msg* }
@__const.main.devChar = [11 x i8] c"/dev/i2c-0\00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"0x%x|%X\00"
@stderr = global i32 0
@.str.2 = [72 x i8] c"Usage:%s [dev:0-2] [addr:0x0-0xFE] [[w dat0 dat1 dat2 ...] | [r rlen]]\0A\00"
@.str.3 = [2 x i8] c"W\00"
@.str.4 = [6 x i8] c"%x|%X\00"
@.str.5 = [21 x i8] c"! invalid argument!\0A\00"
@.str.6 = [21 x i8] c"! missing argument!\0A\00"
@.str.7 = [2 x i8] c"R\00"
@.str.8 = [63 x i8] c"dev%d, addr=0x%x, rlen=%d, wlen=%d, wdata=%d, %d, %d, %d, ...\0A\00"
@O_RDWR = global i32 0
@.str.9 = [29 x i8] c"open device i2c (%s) failed\0A\00"
@I2C_SLAVE_FORCE = global i32 0
@.str.10 = [30 x i8] c"i2c set slave address failed\0A\00"
@.str.11 = [24 x i8] c"ioctl write, return %d\0A\00"
@I2C_RDWR = global i32 0
@I2C_M_RD = global i32 0
@.str.12 = [23 x i8] c"ioctl read, return %d\0A\00"
@.str.13 = [23 x i8] c"i2c read data (raw) = \00"
@.str.14 = [4 x i8] c"%X \00"
@.str.15 = [2 x i8] c"\0A\00"
@.str.16 = [24 x i8] c"i2c read data (char) = \00"
@.str.17 = [3 x i8] c"%c\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 [11 x i8]
%10 = alloca i32
%11 = alloca [64 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.i2c_msg
%16 = alloca %struct.i2c_rdwr_ioctl_data
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 0, i32* %8
%18 = bitcast [11 x i8]* %9 to i8*
store i32 0, i32* %10
store i32 0, i32* %12
store i32 0, i32* %13
store i32 -1, i32* %14
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 3
br i1 %20, label %50, label %21
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%29 = icmp ne i32 %28, 1
br i1 %29, label %50, label %30
30: ; preds = %21
%31 = load i8**, i8*** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%37 = icmp ne i32 %36, 1
br i1 %37, label %50, label %38
38: ; preds = %30
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 0
br i1 %40, label %50, label %41
41: ; preds = %38
%42 = load i32, i32* %10
%43 = icmp sgt i32 %42, 255
br i1 %43, label %50, label %44
44: ; preds = %41
%45 = load i32, i32* %8
%46 = icmp slt i32 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %8
%49 = icmp sgt i32 %48, 2
br i1 %49, label %50, label %57
50: ; preds = %47, %44, %41, %38, %30, %21, %2
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i8* %54)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %47
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
%60 = load i8**, i8*** %5
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i64 @strcasecmp(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %108
67: ; preds = %57
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %70
70: ; preds = %91, %67
%71 = load i32, i32* %7
%72 = load i32, i32* %4
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %82
74: ; preds = %70
%75 = load i8**, i8*** %5
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 @sscanf(i8* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%81 = icmp eq i32 1, %80
br label %82
82: ; preds = %74, %70
%83 = phi i1 [ false, %70 ], [ %81, %74 ]
br i1 %83, label %84, label %94
84: ; preds = %82
%85 = load i32, i32* %14
%86 = trunc i32 %85 to i8
%87 = load i32, i32* %12
%88 = add nsw i32 %87, 1
store i32 %88, i32* %12
%89 = sext i32 %87 to i64
%90 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 %89
store i8 %86, i8* %90
br label %91
91: ; preds = %84
%92 = load i32, i32* %7
%93 = add nsw i32 %92, 1
store i32 %93, i32* %7
br label %70
94: ; preds = %82
%95 = load i32, i32* %12
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %107
97: ; preds = %94
%98 = load i32, i32* %7
%99 = load i32, i32* %4
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %105
103: ; preds = %97
%104 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %105
105: ; preds = %103, %101
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %94
br label %108
108: ; preds = %107, %57
%109 = load i32, i32* %7
%110 = load i32, i32* %4
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %140
112: ; preds = %108
%113 = load i8**, i8*** %5
%114 = load i32, i32* %7
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = call i64 @strcasecmp(i8* %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %140
120: ; preds = %112
%121 = load i32, i32* %7
%122 = add nsw i32 %121, 1
store i32 %122, i32* %7
%123 = load i32, i32* %7
%124 = load i32, i32* %4
%125 = icmp slt i32 %123, %124
br i1 %125, label %126, label %136
126: ; preds = %120
%127 = load i8**, i8*** %5
%128 = load i32, i32* %7
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8*, i8** %127, i64 %129
%131 = load i8*, i8** %130
%132 = call i32 @sscanf(i8* %131, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %14)
%133 = icmp eq i32 1, %132
br i1 %133, label %134, label %136
134: ; preds = %126
%135 = load i32, i32* %14
store i32 %135, i32* %13
br label %139
136: ; preds = %126, %120
%137 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%138 = call i32 @exit(i32 1)
unreachable
139: ; preds = %134
br label %140
140: ; preds = %139, %112, %108
%141 = load i32, i32* %8
%142 = load i32, i32* %10
%143 = load i32, i32* %13
%144 = load i32, i32* %12
%145 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%146 = load i8, i8* %145
%147 = zext i8 %146 to i32
%148 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 1
%149 = load i8, i8* %148
%150 = zext i8 %149 to i32
%151 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 2
%152 = load i8, i8* %151
%153 = zext i8 %152 to i32
%154 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 3
%155 = load i8, i8* %154
%156 = zext i8 %155 to i32
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.8, i64 0, i64 0), i32 %141, i32 %142, i32 %143, i32 %144, i32 %147, i32 %150, i32 %153, i32 %156)
%158 = load i32, i32* %8
%159 = add nsw i32 %158, 48
%160 = trunc i32 %159 to i8
%161 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 9
store i8 %160, i8* %161
%162 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%163 = load i32, i32* @O_RDWR
%164 = call i32 @open(i8* %162, i32 %163)
store i32 %164, i32* %6
%165 = load i32, i32* %6
%166 = icmp slt i32 %165, 0
br i1 %166, label %167, label %171
167: ; preds = %140
%168 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %168)
%170 = call i32 @exit(i32 1)
unreachable
171: ; preds = %140
%172 = load i32, i32* %6
%173 = load i32, i32* @I2C_SLAVE_FORCE
%174 = load i32, i32* %10
%175 = call i32 (i32, i32, ...) @ioctl(i32 %172, i32 %173, i32 %174)
%176 = icmp slt i32 %175, 0
br i1 %176, label %177, label %182
177: ; preds = %171
%178 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%179 = load i32, i32* %6
%180 = call i32 @close(i32 %179)
%181 = call i32 @exit(i32 1)
unreachable
182: ; preds = %171
%183 = load i32, i32* %10
%184 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 0
store i32 %183, i32* %184
%185 = load i32, i32* %12
%186 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 1
store i32 %185, i32* %186
%187 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%188 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 2
store i8* %187, i8** %188
%189 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 3
store i32 0, i32* %189
%190 = getelementptr inbounds %struct.i2c_rdwr_ioctl_data, %struct.i2c_rdwr_ioctl_data* %16, i32 0, i32 0
store i32 1, i32* %190
%191 = getelementptr inbounds %struct.i2c_rdwr_ioctl_data, %struct.i2c_rdwr_ioctl_data* %16, i32 0, i32 1
store %struct.i2c_msg* %15, %struct.i2c_msg** %191
%192 = load i32, i32* %12
%193 = icmp ne i32 %192, 0
br i1 %193, label %194, label %199
194: ; preds = %182
%195 = load i32, i32* %6
%196 = load i32, i32* @I2C_RDWR
%197 = call i32 (i32, i32, ...) @ioctl(i32 %195, i32 %196, %struct.i2c_rdwr_ioctl_data* %16)
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %197)
br label %199
199: ; preds = %194, %182
%200 = call i32 @sleep(i32 1)
%201 = load i32, i32* %13
%202 = icmp ne i32 %201, 0
br i1 %202, label %203, label %214
203: ; preds = %199
%204 = load i32, i32* %13
%205 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 1
store i32 %204, i32* %205
%206 = load i32, i32* @I2C_M_RD
%207 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %15, i32 0, i32 3
%208 = load i32, i32* %207
%209 = or i32 %208, %206
store i32 %209, i32* %207
%210 = load i32, i32* %6
%211 = load i32, i32* @I2C_RDWR
%212 = call i32 (i32, i32, ...) @ioctl(i32 %210, i32 %211, %struct.i2c_rdwr_ioctl_data* %16)
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), i32 %212)
br label %214
214: ; preds = %203, %199
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %17
br label %216
216: ; preds = %227, %214
%217 = load i32, i32* %17
%218 = load i32, i32* %13
%219 = icmp slt i32 %217, %218
br i1 %219, label %220, label %230
220: ; preds = %216
%221 = load i32, i32* %17
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 %222
%224 = load i8, i8* %223
%225 = zext i8 %224 to i32
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 %225)
br label %227
227: ; preds = %220
%228 = load i32, i32* %17
%229 = add nsw i32 %228, 1
store i32 %229, i32* %17
br label %216
230: ; preds = %216
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %17
br label %233
233: ; preds = %244, %230
%234 = load i32, i32* %17
%235 = load i32, i32* %13
%236 = icmp slt i32 %234, %235
br i1 %236, label %237, label %247
237: ; preds = %233
%238 = load i32, i32* %17
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 %239
%241 = load i8, i8* %240
%242 = zext i8 %241 to i32
%243 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32 %242)
br label %244
244: ; preds = %237
%245 = load i32, i32* %17
%246 = add nsw i32 %245, 1
store i32 %246, i32* %17
br label %233
247: ; preds = %233
%248 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%249 = load i32, i32* %6
%250 = call i32 @close(i32 %249)
ret i32 0
}

LLVM IR (-O2):
%struct.i2c_msg = type { i32, i32, i8*, i32 }
%struct.i2c_rdwr_ioctl_data = type { i32, %struct.i2c_msg* }
@__const.main.devChar = [11 x i8] c"/dev/i2c-0\00"
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"0x%x|%X\00"
@stderr = global i32 0
@.str.2 = [72 x i8] c"Usage:%s [dev:0-2] [addr:0x0-0xFE] [[w dat0 dat1 dat2 ...] | [r rlen]]\0A\00"
@.str.3 = [2 x i8] c"W\00"
@.str.4 = [6 x i8] c"%x|%X\00"
@.str.5 = [21 x i8] c"! invalid argument!\0A\00"
@.str.6 = [21 x i8] c"! missing argument!\0A\00"
@.str.7 = [2 x i8] c"R\00"
@.str.8 = [63 x i8] c"dev%d, addr=0x%x, rlen=%d, wlen=%d, wdata=%d, %d, %d, %d, ...\0A\00"
@O_RDWR = global i32 0
@.str.9 = [29 x i8] c"open device i2c (%s) failed\0A\00"
@I2C_SLAVE_FORCE = global i32 0
@.str.10 = [30 x i8] c"i2c set slave address failed\0A\00"
@.str.11 = [24 x i8] c"ioctl write, return %d\0A\00"
@I2C_RDWR = global i32 0
@I2C_M_RD = global i32 0
@.str.12 = [23 x i8] c"ioctl read, return %d\0A\00"
@.str.13 = [23 x i8] c"i2c read data (raw) = \00"
@.str.14 = [4 x i8] c"%X \00"
@.str.16 = [24 x i8] c"i2c read data (char) = \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = alloca i32
%6 = alloca [64 x i8]
%7 = alloca i32
%8 = alloca %struct.i2c_msg
%9 = alloca %struct.i2c_rdwr_ioctl_data
%10 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%12 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
store i32 -1, i32* %7
%15 = icmp slt i32 %0, 3
br i1 %15, label %36, label %16
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%25 = icmp ne i32 %24, 1
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
%29 = icmp sgt i32 %26, 255
%30 = select i1 %28, i1 true, i1 %29
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 0
%33 = select i1 %30, i1 true, i1 %32
%34 = icmp sgt i32 %31, 2
%35 = select i1 %33, i1 true, i1 %34
br i1 %35, label %36, label %41
36: ; preds = %21, %16, %2
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %1
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %21
%42 = getelementptr inbounds i8*, i8** %1, i64 3
%43 = load i8*, i8** %42
%44 = call i64 @strcasecmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %76
46: ; preds = %41
%47 = icmp ugt i32 %0, 4
br i1 %47, label %48, label %72
48: ; preds = %46
%49 = add nsw i32 %0, -4
%50 = zext i32 %49 to i64
br label %51
51: ; preds = %48, %58
%52 = phi i64 [ 4, %48 ], [ %63, %58 ]
%53 = phi i64 [ 0, %48 ], [ %61, %58 ]
%54 = getelementptr inbounds i8*, i8** %1, i64 %52
%55 = load i8*, i8** %54
%56 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %65
58: ; preds = %51
%59 = load i32, i32* %7
%60 = trunc i32 %59 to i8
%61 = add nuw nsw i64 %53, 1
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %53
store i8 %60, i8* %62
%63 = add nuw nsw i64 %52, 1
%64 = icmp eq i64 %61, %50
br i1 %64, label %69, label %51
65: ; preds = %51
%66 = trunc i64 %52 to i32
%67 = trunc i64 %53 to i32
%68 = icmp eq i32 %67, 0
br i1 %68, label %72, label %76
69: ; preds = %58
%70 = trunc i64 %63 to i32
%71 = icmp eq i32 %49, 0
br i1 %71, label %72, label %76
72: ; preds = %69, %46, %65
%73 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %65 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), %46 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), %69 ]
%74 = call i32 @perror(i8* %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %69, %65, %41
%77 = phi i32 [ %66, %65 ], [ 3, %41 ], [ %70, %69 ]
%78 = phi i32 [ %67, %65 ], [ 0, %41 ], [ %49, %69 ]
%79 = icmp slt i32 %77, %0
br i1 %79, label %80, label %100
80: ; preds = %76
%81 = zext i32 %77 to i64
%82 = getelementptr inbounds i8*, i8** %1, i64 %81
%83 = load i8*, i8** %82
%84 = call i64 @strcasecmp(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %100
86: ; preds = %80
%87 = add nuw nsw i32 %77, 1
%88 = icmp slt i32 %87, %0
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = zext i32 %87 to i64
%91 = getelementptr inbounds i8*, i8** %1, i64 %90
%92 = load i8*, i8** %91
%93 = call i32 @sscanf(i8* %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %97
95: ; preds = %89
%96 = load i32, i32* %7
br label %100
97: ; preds = %89, %86
%98 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %95, %80, %76
%101 = phi i32 [ %96, %95 ], [ 0, %80 ], [ 0, %76 ]
%102 = load i32, i32* %3
%103 = load i32, i32* %5
%104 = load i8, i8* %13
%105 = zext i8 %104 to i32
%106 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 1
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 2
%110 = load i8, i8* %109
%111 = zext i8 %110 to i32
%112 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 3
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.8, i64 0, i64 0), i32 %102, i32 %103, i32 %101, i32 %78, i32 %105, i32 %108, i32 %111, i32 %114)
%116 = load i32, i32* %3
%117 = trunc i32 %116 to i8
%118 = add i8 %117, 48
%119 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 9
store i8 %118, i8* %119
%120 = load i32, i32* @O_RDWR
%121 = call i32 @open(i8* %11, i32 %120)
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %100
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %11)
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %100
%127 = load i32, i32* @I2C_SLAVE_FORCE
%128 = load i32, i32* %5
%129 = call i32 (i32, i32, ...) @ioctl(i32 %121, i32 %127, i32 %128)
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %126
%132 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%133 = call i32 @close(i32 %121)
%134 = call i32 @exit(i32 1)
unreachable
135: ; preds = %126
%136 = bitcast %struct.i2c_msg* %8 to i8*
%137 = bitcast %struct.i2c_rdwr_ioctl_data* %9 to i8*
%138 = load i32, i32* %5
%139 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %8, i64 0, i32 0
store i32 %138, i32* %139
%140 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %8, i64 0, i32 1
store i32 %78, i32* %140
%141 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %8, i64 0, i32 2
store i8* %13, i8** %141
%142 = getelementptr inbounds %struct.i2c_msg, %struct.i2c_msg* %8, i64 0, i32 3
store i32 0, i32* %142
%143 = getelementptr inbounds %struct.i2c_rdwr_ioctl_data, %struct.i2c_rdwr_ioctl_data* %9, i64 0, i32 0
store i32 1, i32* %143
%144 = getelementptr inbounds %struct.i2c_rdwr_ioctl_data, %struct.i2c_rdwr_ioctl_data* %9, i64 0, i32 1
store %struct.i2c_msg* %8, %struct.i2c_msg** %144
%145 = icmp eq i32 %78, 0
br i1 %145, label %150, label %146
146: ; preds = %135
%147 = load i32, i32* @I2C_RDWR
%148 = call i32 (i32, i32, ...) @ioctl(i32 %121, i32 %147, %struct.i2c_rdwr_ioctl_data* %9)
%149 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %148)
br label %150
150: ; preds = %146, %135
%151 = call i32 @sleep(i32 1)
%152 = icmp eq i32 %101, 0
br i1 %152, label %153, label %155
153: ; preds = %150
%154 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
br label %187
155: ; preds = %150
store i32 %101, i32* %140
%156 = load i32, i32* @I2C_M_RD
%157 = load i32, i32* %142
%158 = or i32 %157, %156
store i32 %158, i32* %142
%159 = load i32, i32* @I2C_RDWR
%160 = call i32 (i32, i32, ...) @ioctl(i32 %121, i32 %159, %struct.i2c_rdwr_ioctl_data* %9)
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0), i32 %160)
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0))
%163 = icmp sgt i32 %101, 0
br i1 %163, label %164, label %187
164: ; preds = %155
%165 = zext i32 %101 to i64
br label %166
166: ; preds = %164, %166
%167 = phi i64 [ 0, %164 ], [ %172, %166 ]
%168 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %167
%169 = load i8, i8* %168
%170 = zext i8 %169 to i32
%171 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 %170)
%172 = add nuw nsw i64 %167, 1
%173 = icmp eq i64 %172, %165
br i1 %173, label %174, label %166
174: ; preds = %166
%175 = call i32 @putchar(i32 10)
%176 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
br i1 %163, label %177, label %190
177: ; preds = %174
%178 = zext i32 %101 to i64
br label %179
179: ; preds = %177, %179
%180 = phi i64 [ 0, %177 ], [ %185, %179 ]
%181 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %180
%182 = load i8, i8* %181
%183 = zext i8 %182 to i32
%184 = call i32 @putchar(i32 %183)
%185 = add nuw nsw i64 %180, 1
%186 = icmp eq i64 %185, %178
br i1 %186, label %190, label %179
187: ; preds = %155, %153
%188 = call i32 @putchar(i32 10)
%189 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
br label %190
190: ; preds = %179, %187, %174
%191 = call i32 @putchar(i32 10)
%192 = call i32 @close(i32 %121)
ret i32 0
}