#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 SMBWriteBlock(int, int, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ usleep(int);
int writeEepromBlock(unsigned char blockNr, unsigned char *buf) {
  int status;
  unsigned char block[33];
  block[0] = blockNr;
  memcpy(block + 1, buf, 32);
  status = SMBWriteBlock(0x16, 0x10, block, 33);
  usleep(2000);
  return (status > 0 ? status - 1 : status);
}


x86 assembly (clang, -O0):
<writeEepromBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x1(%rbp),%al
mov    %al,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdx
mov    $0x16,%edi
mov    $0x10,%esi
mov    $0x21,%ecx
call   1030 <SMBWriteBlock@plt>
mov    %eax,-0x14(%rbp)
mov    $0x7d0,%edi
call   1050 <usleep@plt>
cmpl   $0x0,-0x14(%rbp)
jle    119b <writeEepromBlock+0x6b>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a1 <writeEepromBlock+0x71>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeEepromBlock>:
push   %rbx
sub    $0x30,%rsp
mov    %dil,(%rsp)
lea    0x1(%rsp),%rdi
mov    $0x20,%edx
call   1040 <memcpy@plt>
mov    %rsp,%rdx
mov    $0x16,%edi
mov    $0x10,%esi
mov    $0x21,%ecx
call   1030 <SMBWriteBlock@plt>
mov    %eax,%ebx
mov    $0x7d0,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
test   %ebx,%ebx
setg   %al
sub    %eax,%ebx
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @writeEepromBlock(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [33 x i8]
store i8 %0, i8* %3
store i8* %1, i8** %4
%7 = load i8, i8* %3
%8 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
store i8 %7, i8* %8
%9 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8*, i8** %4
%12 = call i32 @memcpy(i8* %10, i8* %11, i32 32)
%13 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%14 = call i32 @SMBWriteBlock(i32 22, i32 16, i8* %13, i32 33)
store i32 %14, i32* %5
%15 = call i32 @usleep(i32 2000)
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
br label %23
21: ; preds = %2
%22 = load i32, i32* %5
br label %23
23: ; preds = %21, %18
%24 = phi i32 [ %20, %18 ], [ %22, %21 ]
ret i32 %24
}

LLVM IR (-O2):
define i32 @writeEepromBlock(i8 zeroext %0, i8* %1) {
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
store i8 %0, i8* %4
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 1
%6 = call i32 @memcpy(i8* %5, i8* %1, i32 32)
%7 = call i32 @SMBWriteBlock(i32 22, i32 16, i8* %4, i32 33)
%8 = call i32 @usleep(i32 2000)
%9 = icmp sgt i32 %7, 0
%10 = sext i1 %9 to i32
%11 = add nsw i32 %7, %10
ret i32 %11
}