#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ I2C_SLAVE;
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
int write(int, scalar_t__ *, int);
void write8(int fh, uint8_t d0, uint8_t d1) {
  uint8_t d[2];
  d[0] = (uint8_t)d0;
  d[1] = (uint8_t)d1;
  if (ioctl(fh, I2C_SLAVE, 0x40) < 0)
    printf("ERROR in write8: ioctl\n");
  if (write(fh, d, 2) != 2)
    printf("ERROR in write8: write\n");
  usleep(10);
}


x86 assembly (clang, -O0):
<write8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    118f <write8+0x4f>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
cmp    $0x2,%eax
je     11b5 <write8+0x75>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1060 <usleep@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write8>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %rsi,(%rsp)
mov    %rdx,0x8(%rsp)
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edx
call   1050 <ioctl@plt>
test   %rax,%rax
jns    1174 <write8+0x34>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1040 <write@plt>
cmp    $0x2,%eax
je     1194 <write8+0x54>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <usleep@plt>

LLVM IR (-O0):
@I2C_SLAVE = global i32 0
@.str = [24 x i8] c"ERROR in write8: ioctl\0A\00"
@.str.1 = [24 x i8] c"ERROR in write8: write\0A\00"
define void @write8(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca [2 x i64]
store i32 %0, i32* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %5
%9 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
store i64 %8, i64* %9
%10 = load i64, i64* %6
%11 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 %10, i64* %11
%12 = load i32, i32* %4
%13 = load i32, i32* @I2C_SLAVE
%14 = call i64 @ioctl(i32 %12, i32 %13, i32 64)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %3
%19 = load i32, i32* %4
%20 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%21 = call i32 @write(i32 %19, i64* %20, i32 2)
%22 = icmp ne i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
%26 = call i32 @usleep(i32 10)
ret void
}

LLVM IR (-O2):
@I2C_SLAVE = global i32 0
@str = [23 x i8] c"ERROR in write8: write\00"
@str.2 = [23 x i8] c"ERROR in write8: ioctl\00"
define void @write8(i32 %0, i64 %1, i64 %2) {
%4 = alloca [2 x i64]
%5 = bitcast [2 x i64]* %4 to i8*
%6 = getelementptr inbounds [2 x i64], [2 x i64]* %4, i64 0, i64 0
store i64 %1, i64* %6
%7 = getelementptr inbounds [2 x i64], [2 x i64]* %4, i64 0, i64 1
store i64 %2, i64* %7
%8 = load i32, i32* @I2C_SLAVE
%9 = tail call i64 @ioctl(i32 %0, i32 %8, i32 64)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = call i32 @write(i32 %0, i64* %6, i32 2)
%15 = icmp eq i32 %14, 2
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = tail call i32 @usleep(i32 10)
ret void
}