#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*/ inb(int);
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ smbus_reset();
int /*<<< orphan*/ smbus_wait_until_ready();
void set_ics_data(unsigned char dev, int data, char len) {
  smbus_reset();
  outb(0x00, 0x0500 + 0x5);
  outb(0x80, 0x80);
  smbus_wait_until_ready();
  inb(0x0500 + 0x2);
  if (dev == 0xd2) {
    outb(0x0d, 0x0500 + 0x7);
    outb(0x00, 0x0500 + 0x7);
    outb(0x3f, 0x0500 + 0x7);
    outb(0xcd, 0x0500 + 0x7);
    outb(0x7f, 0x0500 + 0x7);
    outb(0xbf, 0x0500 + 0x7);
    outb(0x1a, 0x0500 + 0x7);
    outb(0x2a, 0x0500 + 0x7);
    outb(0x01, 0x0500 + 0x7);
    outb(0x0f, 0x0500 + 0x7);
    outb(0x0b, 0x0500 + 0x7);
    outb(0x80, 0x0500 + 0x7);
    outb(0x8d, 0x0500 + 0x7);
    outb(0x9b, 0x0500 + 0x7);
  } else {
    outb(0x08, 0x0500 + 0x7);
    outb(0xff, 0x0500 + 0x7);
    outb(0x3f, 0x0500 + 0x7);
    outb(0x00, 0x0500 + 0x7);
    outb(0x00, 0x0500 + 0x7);
    outb(0xff, 0x0500 + 0x7);
    outb(0xff, 0x0500 + 0x7);
    outb(0xff, 0x0500 + 0x7);
    outb(0xff, 0x0500 + 0x7);
  }
  outb(dev, 0x0500 + 0x4);
  outb(0, 0x0500 + 0x3);
  outb(len, 0x0500 + 0x5);
  outb(0x74, 0x0500 + 0x2);
  outb(0x80, 0x80);
  smbus_wait_until_ready();
  smbus_reset();
}


x86 assembly (clang, -O0):
<set_ics_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    $0x0,%al
call   1060 <smbus_reset@plt>
xor    %edi,%edi
mov    $0x505,%esi
call   1030 <outb@plt>
mov    $0x80,%esi
mov    %esi,%edi
call   1030 <outb@plt>
mov    $0x0,%al
call   1050 <smbus_wait_until_ready@plt>
mov    $0x502,%edi
call   1040 <inb@plt>
movzbl -0x1(%rbp),%eax
cmp    $0xd2,%eax
jne    1269 <set_ics_data+0x129>
mov    $0xd,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x3f,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xcd,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x7f,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xbf,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x1a,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x2a,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x1,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xf,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xb,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x80,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x8d,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x9b,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
jmp    12ea <set_ics_data+0x1aa>
mov    $0x8,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xff,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x3f,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xff,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xff,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xff,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xff,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
movzbl -0x1(%rbp),%edi
mov    $0x504,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x503,%esi
call   1030 <outb@plt>
movsbl -0x9(%rbp),%edi
mov    $0x505,%esi
call   1030 <outb@plt>
mov    $0x74,%edi
mov    $0x502,%esi
call   1030 <outb@plt>
mov    $0x80,%esi
mov    %esi,%edi
call   1030 <outb@plt>
mov    $0x0,%al
call   1050 <smbus_wait_until_ready@plt>
mov    $0x0,%al
call   1060 <smbus_reset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ics_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x14(%rsp)
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <smbus_reset@plt>
xor    %edi,%edi
mov    $0x505,%esi
call   1030 <outb@plt>
mov    $0x80,%edi
mov    $0x80,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1050 <smbus_wait_until_ready@plt>
mov    $0x502,%edi
call   1040 <inb@plt>
mov    %ebx,0x10(%rsp)
cmp    $0xd2,%bl
jne    1217 <set_ics_data+0xd7>
mov    $0xd,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x3f,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0xcd,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    $0x7f,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
movl   $0x9b,0xc(%rsp)
movl   $0x8d,0x8(%rsp)
mov    $0x80,%ebx
mov    $0xb,%r14d
mov    $0xf,%r15d
mov    $0x1,%ebp
mov    $0x2a,%r12d
mov    $0x1a,%r13d
mov    $0xbf,%edi
jmp    1246 <set_ics_data+0x106>
mov    $0x3f,%r12d
mov    $0xff,%r13d
mov    $0x8,%edi
xor    %r15d,%r15d
mov    $0xff,%r14d
mov    $0xff,%ebx
movl   $0xff,0x8(%rsp)
movl   $0xff,0xc(%rsp)
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %r13d,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %r12d,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %ebp,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %r15d,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %r14d,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    0x8(%rsp),%edi
mov    $0x507,%esi
call   1030 <outb@plt>
mov    0xc(%rsp),%edi
mov    $0x507,%esi
call   1030 <outb@plt>
movzbl 0x10(%rsp),%edi
mov    $0x504,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    $0x503,%esi
call   1030 <outb@plt>
movsbl 0x14(%rsp),%edi
mov    $0x505,%esi
call   1030 <outb@plt>
mov    $0x74,%edi
mov    $0x502,%esi
call   1030 <outb@plt>
mov    $0x80,%edi
mov    $0x80,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1050 <smbus_wait_until_ready@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <smbus_reset@plt>

LLVM IR (-O0):
define void @set_ics_data(i8 zeroext %0, i32 %1, i8 signext %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
store i8 %0, i8* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = call i32 (...) @smbus_reset()
%8 = call i32 @outb(i32 0, i32 1285)
%9 = call i32 @outb(i32 128, i32 128)
%10 = call i32 (...) @smbus_wait_until_ready()
%11 = call i32 @inb(i32 1282)
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 210
br i1 %14, label %15, label %30
15: ; preds = %3
%16 = call i32 @outb(i32 13, i32 1287)
%17 = call i32 @outb(i32 0, i32 1287)
%18 = call i32 @outb(i32 63, i32 1287)
%19 = call i32 @outb(i32 205, i32 1287)
%20 = call i32 @outb(i32 127, i32 1287)
%21 = call i32 @outb(i32 191, i32 1287)
%22 = call i32 @outb(i32 26, i32 1287)
%23 = call i32 @outb(i32 42, i32 1287)
%24 = call i32 @outb(i32 1, i32 1287)
%25 = call i32 @outb(i32 15, i32 1287)
%26 = call i32 @outb(i32 11, i32 1287)
%27 = call i32 @outb(i32 128, i32 1287)
%28 = call i32 @outb(i32 141, i32 1287)
%29 = call i32 @outb(i32 155, i32 1287)
br label %40
30: ; preds = %3
%31 = call i32 @outb(i32 8, i32 1287)
%32 = call i32 @outb(i32 255, i32 1287)
%33 = call i32 @outb(i32 63, i32 1287)
%34 = call i32 @outb(i32 0, i32 1287)
%35 = call i32 @outb(i32 0, i32 1287)
%36 = call i32 @outb(i32 255, i32 1287)
%37 = call i32 @outb(i32 255, i32 1287)
%38 = call i32 @outb(i32 255, i32 1287)
%39 = call i32 @outb(i32 255, i32 1287)
br label %40
40: ; preds = %30, %15
%41 = load i8, i8* %4
%42 = zext i8 %41 to i32
%43 = call i32 @outb(i32 %42, i32 1284)
%44 = call i32 @outb(i32 0, i32 1283)
%45 = load i8, i8* %6
%46 = sext i8 %45 to i32
%47 = call i32 @outb(i32 %46, i32 1285)
%48 = call i32 @outb(i32 116, i32 1282)
%49 = call i32 @outb(i32 128, i32 128)
%50 = call i32 (...) @smbus_wait_until_ready()
%51 = call i32 (...) @smbus_reset()
ret void
}

LLVM IR (-O2):
define void @set_ics_data(i8 zeroext %0, i32 %1, i8 signext %2) {
%4 = tail call i32 (...) @smbus_reset()
%5 = tail call i32 @outb(i32 0, i32 1285)
%6 = tail call i32 @outb(i32 128, i32 128)
%7 = tail call i32 (...) @smbus_wait_until_ready()
%8 = tail call i32 @inb(i32 1282)
%9 = icmp eq i8 %0, -46
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = tail call i32 @outb(i32 13, i32 1287)
%12 = tail call i32 @outb(i32 0, i32 1287)
%13 = tail call i32 @outb(i32 63, i32 1287)
%14 = tail call i32 @outb(i32 205, i32 1287)
%15 = tail call i32 @outb(i32 127, i32 1287)
br label %16
16: ; preds = %3, %10
%17 = phi i32 [ 191, %10 ], [ 8, %3 ]
%18 = phi i32 [ 26, %10 ], [ 255, %3 ]
%19 = phi i32 [ 42, %10 ], [ 63, %3 ]
%20 = phi i32 [ 1, %10 ], [ 0, %3 ]
%21 = phi i32 [ 15, %10 ], [ 0, %3 ]
%22 = phi i32 [ 11, %10 ], [ 255, %3 ]
%23 = phi i32 [ 128, %10 ], [ 255, %3 ]
%24 = phi i32 [ 141, %10 ], [ 255, %3 ]
%25 = phi i32 [ 155, %10 ], [ 255, %3 ]
%26 = tail call i32 @outb(i32 %17, i32 1287)
%27 = tail call i32 @outb(i32 %18, i32 1287)
%28 = tail call i32 @outb(i32 %19, i32 1287)
%29 = tail call i32 @outb(i32 %20, i32 1287)
%30 = tail call i32 @outb(i32 %21, i32 1287)
%31 = tail call i32 @outb(i32 %22, i32 1287)
%32 = tail call i32 @outb(i32 %23, i32 1287)
%33 = tail call i32 @outb(i32 %24, i32 1287)
%34 = tail call i32 @outb(i32 %25, i32 1287)
%35 = zext i8 %0 to i32
%36 = tail call i32 @outb(i32 %35, i32 1284)
%37 = tail call i32 @outb(i32 0, i32 1283)
%38 = sext i8 %2 to i32
%39 = tail call i32 @outb(i32 %38, i32 1285)
%40 = tail call i32 @outb(i32 116, i32 1282)
%41 = tail call i32 @outb(i32 128, i32 128)
%42 = tail call i32 (...) @smbus_wait_until_ready()
%43 = tail call i32 (...) @smbus_reset()
ret void
}