#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 */
void *I2C1_Rd(int);
int /*<<< orphan*/ I2C1_Repeated_Start();
int /*<<< orphan*/ I2C1_Start();
int /*<<< orphan*/ I2C1_Stop();
int /*<<< orphan*/ I2C1_Wr(int);
void RTC_Read_RAM(char *values, int size) {
  int i;
  I2C1_Start();
  I2C1_Wr(0xD0);
  I2C1_Wr(8);
  I2C1_Repeated_Start();
  I2C1_Wr(0xD1);
  for (i = 0; i < size - 1; i++)
    *values++ = I2C1_Rd(1);
  *values = I2C1_Rd(0);
  I2C1_Stop();
}


x86 assembly (clang, -O0):
<RTC_Read_RAM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1060 <I2C1_Start@plt>
mov    $0xd0,%edi
call   1050 <I2C1_Wr@plt>
mov    $0x8,%edi
call   1050 <I2C1_Wr@plt>
mov    $0x0,%al
call   1070 <I2C1_Repeated_Start@plt>
mov    $0xd1,%edi
call   1050 <I2C1_Wr@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ce <RTC_Read_RAM+0x7e>
mov    $0x1,%edi
call   1030 <I2C1_Rd@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1192 <RTC_Read_RAM+0x42>
xor    %edi,%edi
call   1030 <I2C1_Rd@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    $0x0,%al
call   1040 <I2C1_Stop@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RTC_Read_RAM>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <I2C1_Start@plt>
mov    $0xd0,%edi
call   1050 <I2C1_Wr@plt>
mov    $0x8,%edi
call   1050 <I2C1_Wr@plt>
xor    %eax,%eax
call   1070 <I2C1_Repeated_Start@plt>
mov    $0xd1,%edi
call   1050 <I2C1_Wr@plt>
cmp    $0x2,%ebp
jl     11a5 <RTC_Read_RAM+0x55>
add    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    $0x1,%edi
call   1030 <I2C1_Rd@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%ebp
jne    1190 <RTC_Read_RAM+0x40>
xor    %edi,%edi
call   1030 <I2C1_Rd@plt>
mov    %al,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <I2C1_Stop@plt>

LLVM IR (-O0):
define void @RTC_Read_RAM(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (...) @I2C1_Start()
%7 = call i32 @I2C1_Wr(i32 208)
%8 = call i32 @I2C1_Wr(i32 8)
%9 = call i32 (...) @I2C1_Repeated_Start()
%10 = call i32 @I2C1_Wr(i32 209)
store i32 0, i32* %5
br label %11
11: ; preds = %21, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = call i8* @I2C1_Rd(i32 1)
%18 = ptrtoint i8* %17 to i8
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 %18, i8* %19
br label %21
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %11
24: ; preds = %11
%25 = call i8* @I2C1_Rd(i32 0)
%26 = ptrtoint i8* %25 to i8
%27 = load i8*, i8** %3
store i8 %26, i8* %27
%28 = call i32 (...) @I2C1_Stop()
ret void
}

LLVM IR (-O2):
define void @RTC_Read_RAM(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 (...) @I2C1_Start()
%4 = tail call i32 @I2C1_Wr(i32 208)
%5 = tail call i32 @I2C1_Wr(i32 8)
%6 = tail call i32 (...) @I2C1_Repeated_Start()
%7 = tail call i32 @I2C1_Wr(i32 209)
%8 = add i32 %1, -1
%9 = icmp sgt i32 %1, 1
br i1 %9, label %10, label %19
10: ; preds = %2, %10
%11 = phi i32 [ %17, %10 ], [ 0, %2 ]
%12 = phi i8* [ %16, %10 ], [ %0, %2 ]
%13 = tail call i8* @I2C1_Rd(i32 1)
%14 = ptrtoint i8* %13 to i64
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %15, i8* %12
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, %8
br i1 %18, label %19, label %10
19: ; preds = %10, %2
%20 = phi i8* [ %0, %2 ], [ %16, %10 ]
%21 = tail call i8* @I2C1_Rd(i32 0)
%22 = ptrtoint i8* %21 to i64
%23 = trunc i64 %22 to i8
store i8 %23, i8* %20
%24 = tail call i32 (...) @I2C1_Stop()
ret void
}