#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*/ I2C1_Start();
int /*<<< orphan*/ I2C1_Stop();
int /*<<< orphan*/ I2C1_Wr(unsigned char);
int /*<<< orphan*/ delay_ms(int);
void eepromWrite(int deviceAddress, unsigned int memAddress,
                 unsigned char value) {
  I2C1_Start();
  I2C1_Wr(0xa0 + (deviceAddress << 1) + 0);
  I2C1_Wr(memAddress >> 8);
  I2C1_Wr(memAddress & 0xff);
  I2C1_Wr(value);
  I2C1_Stop();
  delay_ms(100);
}


x86 assembly (clang, -O0):
<eepromWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    $0x0,%al
call   1050 <I2C1_Start@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    $0xa0,%eax
add    $0x0,%eax
movzbl %al,%edi
call   1040 <I2C1_Wr@plt>
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
movzbl %al,%edi
call   1040 <I2C1_Wr@plt>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
movzbl %al,%edi
call   1040 <I2C1_Wr@plt>
movzbl -0x9(%rbp),%edi
call   1040 <I2C1_Wr@plt>
mov    $0x0,%al
call   1030 <I2C1_Stop@plt>
mov    $0x64,%edi
call   1060 <delay_ms@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eepromWrite>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <I2C1_Start@plt>
add    %bpl,%bpl
add    $0xa0,%bpl
movzbl %bpl,%edi
call   1040 <I2C1_Wr@plt>
movzbl %bh,%edi
call   1040 <I2C1_Wr@plt>
movzbl %bl,%edi
call   1040 <I2C1_Wr@plt>
mov    %r14d,%edi
call   1040 <I2C1_Wr@plt>
xor    %eax,%eax
call   1030 <I2C1_Stop@plt>
mov    $0x64,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <delay_ms@plt>

LLVM IR (-O0):
define void @eepromWrite(i32 %0, i32 %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = call i32 (...) @I2C1_Start()
%8 = load i32, i32* %4
%9 = shl i32 %8, 1
%10 = add nsw i32 160, %9
%11 = add nsw i32 %10, 0
%12 = trunc i32 %11 to i8
%13 = call i32 @I2C1_Wr(i8 zeroext %12)
%14 = load i32, i32* %5
%15 = lshr i32 %14, 8
%16 = trunc i32 %15 to i8
%17 = call i32 @I2C1_Wr(i8 zeroext %16)
%18 = load i32, i32* %5
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = call i32 @I2C1_Wr(i8 zeroext %20)
%22 = load i8, i8* %6
%23 = call i32 @I2C1_Wr(i8 zeroext %22)
%24 = call i32 (...) @I2C1_Stop()
%25 = call i32 @delay_ms(i32 100)
ret void
}

LLVM IR (-O2):
define void @eepromWrite(i32 %0, i32 %1, i8 zeroext %2) {
%4 = tail call i32 (...) @I2C1_Start()
%5 = trunc i32 %0 to i8
%6 = shl i8 %5, 1
%7 = add i8 %6, -96
%8 = tail call i32 @I2C1_Wr(i8 zeroext %7)
%9 = lshr i32 %1, 8
%10 = trunc i32 %9 to i8
%11 = tail call i32 @I2C1_Wr(i8 zeroext %10)
%12 = trunc i32 %1 to i8
%13 = tail call i32 @I2C1_Wr(i8 zeroext %12)
%14 = tail call i32 @I2C1_Wr(i8 zeroext %2)
%15 = tail call i32 (...) @I2C1_Stop()
%16 = tail call i32 @delay_ms(i32 100)
ret void
}