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

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ I2C_SLAVE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int i2c_smbus_read_word_data(int, int);
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  int fd;
  fd = open("/dev/i2c-1", O_RDWR);
  if (fd <= 1) {
    printf("error on device\n");
    exit(1);
  }
  int addr = 0x09;
  if (ioctl(fd, I2C_SLAVE, addr) < 0) {
    printf("ioctl error\n");
    exit(1);
  }
  while (1) {
    printf(
        "%d %d %d %d %d %d %d %d %d %d\n", i2c_smbus_read_word_data(fd, 0x00),
        i2c_smbus_read_word_data(fd, 0x01), i2c_smbus_read_word_data(fd, 0x02),
        i2c_smbus_read_word_data(fd, 0x03), i2c_smbus_read_word_data(fd, 0x04),
        i2c_smbus_read_word_data(fd, 0x05), i2c_smbus_read_word_data(fd, 0x06),
        i2c_smbus_read_word_data(fd, 0x07),
        i2c_smbus_read_word_data(fd, 0x08) - 0x17cc,
        i2c_smbus_read_word_data(fd, 0x09) - 0x17cc);
    sleep(1);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
movl   $0x0,-0x14(%rbp)
mov    %edi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    0xe77(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jg     11b3 <main+0x53>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x9,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%edx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
jge    11f0 <main+0x90>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11f5 <main+0x95>
mov    -0x24(%rbp),%edi
xor    %esi,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x2,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x40(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x3,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x4,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x5,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,%r14d
mov    -0x24(%rbp),%edi
mov    $0x6,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,%ebx
mov    -0x24(%rbp),%edi
mov    $0x7,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x8,%esi
call   1050 <i2c_smbus_read_word_data@plt>
sub    $0x17cc,%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x9,%esi
call   1050 <i2c_smbus_read_word_data@plt>
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x34(%rbp),%r11d
mov    -0x30(%rbp),%r10d
sub    $0x17cc,%eax
mov    %eax,-0x2c(%rbp)
lea    0xd6e(%rip),%rdi
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    11f5 <main+0x95>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
call   1070 <open@plt>
cmp    $0x1,%eax
jle    12af <main+0x13f>
mov    %eax,%r14d
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    $0x9,%edx
call   1050 <ioctl@plt>
test   %rax,%rax
js     12b8 <main+0x148>
xchg   %ax,%ax
mov    %r14d,%edi
xor    %esi,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,0xc(%rsp)
mov    %r14d,%edi
mov    $0x1,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,0x8(%rsp)
mov    %r14d,%edi
mov    $0x2,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,0x4(%rsp)
mov    %r14d,%edi
mov    $0x3,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,(%rsp)
mov    %r14d,%edi
mov    $0x4,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,%r15d
mov    %r14d,%edi
mov    $0x5,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %rax,0x10(%rsp)
mov    %r14d,%edi
mov    $0x6,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,%r12d
mov    %r14d,%edi
mov    $0x7,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    $0x8,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,%ebp
add    $0xffffe834,%ebp
mov    %r14d,%edi
mov    $0x9,%esi
call   1060 <i2c_smbus_read_word_data@plt>
mov    %eax,%ebx
add    $0xffffe834,%ebx
sub    $0x8,%rsp
lea    0xd94(%rip),%rdi
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    %r15d,%r9d
xor    %eax,%eax
push   %rbx
push   %rbp
push   %r13
push   %r12
push   0x38(%rsp)
call   1040 <printf@plt>
add    $0x30,%rsp
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11c0 <main+0x50>
lea    0xd80(%rip),%rdi
jmp    12bf <main+0x14f>
lea    0xd6b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-1\00"
@O_RDWR = global i32 0
@.str.1 = [17 x i8] c"error on device\0A\00"
@I2C_SLAVE = global i32 0
@.str.2 = [13 x i8] c"ioctl error\0A\00"
@.str.3 = [31 x i8] c"%d %d %d %d %d %d %d %d %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 9, i32* %7
%16 = load i32, i32* %6
%17 = load i32, i32* @I2C_SLAVE
%18 = load i32, i32* %7
%19 = call i64 @ioctl(i32 %16, i32 %17, i32 %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %15
br label %25
25: ; preds = %24, %25
%26 = load i32, i32* %6
%27 = call i32 @i2c_smbus_read_word_data(i32 %26, i32 0)
%28 = load i32, i32* %6
%29 = call i32 @i2c_smbus_read_word_data(i32 %28, i32 1)
%30 = load i32, i32* %6
%31 = call i32 @i2c_smbus_read_word_data(i32 %30, i32 2)
%32 = load i32, i32* %6
%33 = call i32 @i2c_smbus_read_word_data(i32 %32, i32 3)
%34 = load i32, i32* %6
%35 = call i32 @i2c_smbus_read_word_data(i32 %34, i32 4)
%36 = load i32, i32* %6
%37 = call i32 @i2c_smbus_read_word_data(i32 %36, i32 5)
%38 = load i32, i32* %6
%39 = call i32 @i2c_smbus_read_word_data(i32 %38, i32 6)
%40 = load i32, i32* %6
%41 = call i32 @i2c_smbus_read_word_data(i32 %40, i32 7)
%42 = load i32, i32* %6
%43 = call i32 @i2c_smbus_read_word_data(i32 %42, i32 8)
%44 = sub nsw i32 %43, 6092
%45 = load i32, i32* %6
%46 = call i32 @i2c_smbus_read_word_data(i32 %45, i32 9)
%47 = sub nsw i32 %46, 6092
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %29, i32 %31, i32 %33, i32 %35, i32 %37, i32 %39, i32 %41, i32 %44, i32 %47)
%49 = call i32 @sleep(i32 1)
br label %25
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
@.str.3 = [31 x i8] c"%d %d %d %d %d %d %d %d %d %d\0A\00"
@str = [12 x i8] c"ioctl error\00"
@str.4 = [16 x i8] c"error on device\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = load i32, i32* @I2C_SLAVE
%11 = tail call i64 @ioctl(i32 %4, i32 %10, i32 9)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %16
%17 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 0)
%18 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 1)
%19 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 2)
%20 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 3)
%21 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 4)
%22 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 5)
%23 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 6)
%24 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 7)
%25 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 8)
%26 = add nsw i32 %25, -6092
%27 = tail call i32 @i2c_smbus_read_word_data(i32 %4, i32 9)
%28 = add nsw i32 %27, -6092
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %18, i32 %19, i32 %20, i32 %21, i32 %22, i32 %23, i32 %24, i32 %26, i32 %28)
%30 = tail call i32 @sleep(i32 1)
br label %16
}