#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 */
union i2c_smbus_data {
  unsigned char *block;
};

/* Variables and functions */
unsigned char I2C_SMBUS_BLOCK_MAX;
int /*<<< orphan*/ I2C_SMBUS_I2C_BLOCK_DATA;
int /*<<< orphan*/ I2C_SMBUS_WRITE;
long i2c_smbus_access(int, int /*<<< orphan*/, unsigned char,
                      int /*<<< orphan*/, union i2c_smbus_data *);
long i2c_smbus_write_i2c_block_data(int file, unsigned char command,
                                    unsigned char length,
                                    const unsigned char *values) {
  union i2c_smbus_data data;
  int i;
  if (length > I2C_SMBUS_BLOCK_MAX)
    length = I2C_SMBUS_BLOCK_MAX;
  for (i = 1; i <= length; i++)
    data.block[i] = values[i - 1];
  data.block[0] = length;
  return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
                          I2C_SMBUS_I2C_BLOCK_DATA, &data);
}


x86 assembly (clang, -O0):
<i2c_smbus_write_i2c_block_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %edi,-0x4(%rbp)
mov    %dl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    %rcx,-0x10(%rbp)
movzbl -0x6(%rbp),%eax
mov    0x2eab(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jle    114c <i2c_smbus_write_i2c_block_data+0x3c>
mov    0x2e99(%rip),%rax
mov    (%rax),%al
mov    %al,-0x6(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movzbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jg     118b <i2c_smbus_write_i2c_block_data+0x7b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1153 <i2c_smbus_write_i2c_block_data+0x43>
mov    -0x6(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edi
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
mov    -0x5(%rbp),%al
mov    0x2e26(%rip),%rcx
mov    (%rcx),%ecx
lea    -0x18(%rbp),%r8
movzbl %al,%edx
call   1030 <i2c_smbus_access@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%union.i2c_smbus_data = type { i8* }
@I2C_SMBUS_BLOCK_MAX = global i8 0
@I2C_SMBUS_WRITE = global i32 0
@I2C_SMBUS_I2C_BLOCK_DATA = global i32 0
define i64 @i2c_smbus_write_i2c_block_data(i32 %0, i8 zeroext %1, i8 zeroext %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca %union.i2c_smbus_data
%10 = alloca i32
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%11 = load i8, i8* %7
%12 = zext i8 %11 to i32
%13 = load i8, i8* @I2C_SMBUS_BLOCK_MAX
%14 = zext i8 %13 to i32
%15 = icmp sgt i32 %12, %14
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = load i8, i8* @I2C_SMBUS_BLOCK_MAX
store i8 %17, i8* %7
br label %18
18: ; preds = %16, %4
store i32 1, i32* %10
br label %19
19: ; preds = %36, %18
%20 = load i32, i32* %10
%21 = load i8, i8* %7
%22 = zext i8 %21 to i32
%23 = icmp sle i32 %20, %22
br i1 %23, label %24, label %39
24: ; preds = %19
%25 = load i8*, i8** %8
%26 = load i32, i32* %10
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = bitcast %union.i2c_smbus_data* %9 to i8**
%32 = load i8*, i8** %31
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %30, i8* %35
br label %36
36: ; preds = %24
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %19
39: ; preds = %19
%40 = load i8, i8* %7
%41 = bitcast %union.i2c_smbus_data* %9 to i8**
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 0
store i8 %40, i8* %43
%44 = load i32, i32* %5
%45 = load i32, i32* @I2C_SMBUS_WRITE
%46 = load i8, i8* %6
%47 = load i32, i32* @I2C_SMBUS_I2C_BLOCK_DATA
%48 = call i64 @i2c_smbus_access(i32 %44, i32 %45, i8 zeroext %46, i32 %47, %union.i2c_smbus_data* %9)
ret i64 %48
}

LLVM IR (-O2):