#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 */
char gp2x_i2c_read(char, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *gp2x_misc_eeprom(void) {
  static char buffer[86 + 1];
  int i;
  memset(buffer, 0, 86 + 1);
  for (i = 0; i < 86; i++)
    buffer[i] = gp2x_i2c_read('P', i);
  return buffer;
}


x86 assembly (clang, -O0):
<gp2x_misc_eeprom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x2f11(%rip),%rdi
xor    %esi,%esi
mov    $0x57,%edx
call   1040 <memset@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x56,-0x4(%rbp)
jge    1177 <gp2x_misc_eeprom+0x57>
mov    -0x4(%rbp),%esi
mov    $0x50,%edi
call   1030 <gp2x_i2c_read@plt>
mov    %al,%dl
movslq -0x4(%rbp),%rcx
lea    0x2eda(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1142 <gp2x_misc_eeprom+0x22>
lea    0x2ec2(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gp2x_misc_eeprom>:
push   %r14
push   %rbx
push   %rax
lea    0x2f15(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x57,%edx
call   1040 <memset@plt>
nopl   0x0(%rax)
mov    $0x50,%edi
mov    %ebx,%esi
call   1030 <gp2x_i2c_read@plt>
mov    %al,(%rbx,%r14,1)
add    $0x1,%rbx
cmp    $0x56,%rbx
jne    1140 <gp2x_misc_eeprom+0x20>
lea    0x2edf(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@gp2x_misc_eeprom.buffer = internal global [87 x i8] zeroinitializer
define i8* @gp2x_misc_eeprom() {
%1 = alloca i32
%2 = call i32 @memset(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 0), i32 0, i32 87)
store i32 0, i32* %1
br label %3
3: ; preds = %12, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 86
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load i32, i32* %1
%8 = call signext i8 @gp2x_i2c_read(i8 signext 80, i32 %7)
%9 = load i32, i32* %1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 %10
store i8 %8, i8* %11
br label %12
12: ; preds = %6
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
br label %3
15: ; preds = %3
ret i8* getelementptr inbounds ([87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@gp2x_misc_eeprom.buffer = internal global [87 x i8] zeroinitializer
define i8* @gp2x_misc_eeprom() {
%1 = tail call i32 @memset(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 0), i32 0, i32 87)
br label %2
2: ; preds = %0, %2
%3 = phi i64 [ 0, %0 ], [ %7, %2 ]
%4 = trunc i64 %3 to i32
%5 = tail call signext i8 @gp2x_i2c_read(i8 signext 80, i32 %4)
%6 = getelementptr inbounds [87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 %3
store i8 %5, i8* %6
%7 = add nuw nsw i64 %3, 1
%8 = icmp eq i64 %7, 86
br i1 %8, label %9, label %2
9: ; preds = %2
ret i8* getelementptr inbounds ([87 x i8], [87 x i8]* @gp2x_misc_eeprom.buffer, i64 0, i64 0)
}