#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 */
scalar_t__ i2c_write(unsigned char *, int);
int register32_write(unsigned char reg, unsigned int data) {
  int rc = -1;
  unsigned char bite[6];
  bite[0] = reg;
  bite[1] = data & 0xFF;
  bite[2] = (data >> 8) & 0xFF;
  bite[3] = (data >> 16) & 0xFF;
  bite[4] = (data >> 24) & 0xFF;
  if (i2c_write(bite, 5) == 0) {
    rc = 0;
  }
  return rc;
}


x86 assembly (clang, -O0):
<register32_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x1(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,-0xe(%rbp)
lea    -0x12(%rbp),%rdi
mov    $0x5,%esi
call   1030 <i2c_write@plt>
cmp    $0x0,%rax
jne    1182 <register32_write+0x72>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register32_write>:
push   %rax
mov    %esi,%eax
mov    %dil,0x2(%rsp)
mov    %al,0x3(%rsp)
mov    %ah,0x4(%rsp)
mov    %esi,%ecx
shr    $0x10,%ecx
mov    %cl,0x5(%rsp)
shr    $0x18,%eax
mov    %al,0x6(%rsp)
lea    0x2(%rsp),%rdi
mov    $0x5,%esi
call   1030 <i2c_write@plt>
neg    %rax
sbb    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @register32_write(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca [6 x i8]
store i8 %0, i8* %3
store i32 %1, i32* %4
store i32 -1, i32* %5
%7 = load i8, i8* %3
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
store i8 %7, i8* %8
%9 = load i32, i32* %4
%10 = and i32 %9, 255
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 1
store i8 %11, i8* %12
%13 = load i32, i32* %4
%14 = lshr i32 %13, 8
%15 = and i32 %14, 255
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 2
store i8 %16, i8* %17
%18 = load i32, i32* %4
%19 = lshr i32 %18, 16
%20 = and i32 %19, 255
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 3
store i8 %21, i8* %22
%23 = load i32, i32* %4
%24 = lshr i32 %23, 24
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 4
store i8 %26, i8* %27
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%29 = call i64 @i2c_write(i8* %28, i32 5)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %2
store i32 0, i32* %5
br label %32
32: ; preds = %31, %2
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @register32_write(i8 zeroext %0, i32 %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
store i8 %0, i8* %4
%5 = trunc i32 %1 to i8
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
store i8 %5, i8* %6
%7 = lshr i32 %1, 8
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
store i8 %8, i8* %9
%10 = lshr i32 %1, 16
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
store i8 %11, i8* %12
%13 = lshr i32 %1, 24
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
store i8 %14, i8* %15
%16 = call i64 @i2c_write(i8* %4, i32 5)
%17 = icmp ne i64 %16, 0
%18 = sext i1 %17 to i32
ret i32 %18
}