#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 {
  int *block;
};
typedef int __u8;
typedef int /*<<< orphan*/ __s32;

/* Variables and functions */
int I2C_SMBUS_BLOCK_MAX;
int /*<<< orphan*/ I2C_SMBUS_I2C_BLOCK_DATA;
int /*<<< orphan*/ I2C_SMBUS_WRITE;
int /*<<< orphan*/ i2c_smbus_access(int, int /*<<< orphan*/, int,
                                    int /*<<< orphan*/, union i2c_smbus_data *);
__s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length,
                                     const __u8 *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    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2eb1(%rip),%rcx
cmp    (%rcx),%eax
jle    1143 <i2c_smbus_write_i2c_block_data+0x33>
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     117f <i2c_smbus_write_i2c_block_data+0x6f>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114a <i2c_smbus_write_i2c_block_data+0x3a>
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    0x2e32(%rip),%rax
mov    (%rax),%ecx
lea    -0x20(%rbp),%r8
call   1030 <i2c_smbus_access@plt>
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O2):