#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_start();
int /*<<< orphan*/ I2C_stop();
int /*<<< orphan*/ I2C_write(unsigned char);
void EEPROM_pagew(unsigned int addr, unsigned int number,
                  unsigned char *data1) {
  int i;
  I2C_start();
  I2C_write(0xA0);
  I2C_write(addr & 0xF0);
  I2C_write(addr & 0x0F);
  for (i = 0; i < number; i++, data1++)
    I2C_write(*data1);
  I2C_stop();
}


x86 assembly (clang, -O0):
<EEPROM_pagew>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    $0x0,%al
call   1040 <I2C_start@plt>
mov    $0xa0,%edi
call   1050 <I2C_write@plt>
mov    -0x4(%rbp),%eax
and    $0xf0,%eax
movzbl %al,%edi
call   1050 <I2C_write@plt>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
movzbl %al,%edi
call   1050 <I2C_write@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11aa <EEPROM_pagew+0x7a>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1050 <I2C_write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1178 <EEPROM_pagew+0x48>
mov    $0x0,%al
call   1030 <I2C_stop@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EEPROM_pagew>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <I2C_start@plt>
mov    $0xa0,%edi
call   1050 <I2C_write@plt>
mov    %ebp,%edi
and    $0xf0,%edi
call   1050 <I2C_write@plt>
and    $0xf,%ebp
mov    %ebp,%edi
call   1050 <I2C_write@plt>
test   %r14d,%r14d
je     1192 <EEPROM_pagew+0x62>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%edi
call   1050 <I2C_write@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1180 <EEPROM_pagew+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <I2C_stop@plt>

LLVM IR (-O0):
define void @EEPROM_pagew(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = call i32 (...) @I2C_start()
%9 = call i32 @I2C_write(i8 zeroext -96)
%10 = load i32, i32* %4
%11 = and i32 %10, 240
%12 = trunc i32 %11 to i8
%13 = call i32 @I2C_write(i8 zeroext %12)
%14 = load i32, i32* %4
%15 = and i32 %14, 15
%16 = trunc i32 %15 to i8
%17 = call i32 @I2C_write(i8 zeroext %16)
store i32 0, i32* %7
br label %18
18: ; preds = %26, %3
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = call i32 @I2C_write(i8 zeroext %24)
br label %26
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
br label %18
31: ; preds = %18
%32 = call i32 (...) @I2C_stop()
ret void
}

LLVM IR (-O2):
define void @EEPROM_pagew(i32 %0, i32 %1, i8* nocapture %2) {
%4 = tail call i32 (...) @I2C_start()
%5 = tail call i32 @I2C_write(i8 zeroext -96)
%6 = trunc i32 %0 to i8
%7 = and i8 %6, -16
%8 = tail call i32 @I2C_write(i8 zeroext %7)
%9 = and i8 %6, 15
%10 = tail call i32 @I2C_write(i8 zeroext %9)
%11 = icmp eq i32 %1, 0
br i1 %11, label %20, label %12
12: ; preds = %3, %12
%13 = phi i32 [ %17, %12 ], [ 0, %3 ]
%14 = phi i8* [ %18, %12 ], [ %2, %3 ]
%15 = load i8, i8* %14
%16 = tail call i32 @I2C_write(i8 zeroext %15)
%17 = add nuw i32 %13, 1
%18 = getelementptr inbounds i8, i8* %14, i64 1
%19 = icmp eq i32 %17, %1
br i1 %19, label %20, label %12
20: ; preds = %12, %3
%21 = tail call i32 (...) @I2C_stop()
ret void
}