#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 /*<<< orphan*/ printk(char *, char, char);
int /*<<< orphan*/ sensor_i2c_read(char *, int);
int sensor_i2c_write(char *, int);
void sensor_config(void) {
  char buf[10];
  int ret;
  buf[0] = 0x28;
  buf[1] = 0x88;
  ret = sensor_i2c_write(buf, 1);
  if (ret == 0)
    printk("write reg %d value %d ok.", buf[0], buf[1]);
  buf[0] = 0x28;
  sensor_i2c_read(buf + 1, 1);
  printk("reg 0x%x value is 0x%x", buf[0], buf[1]);
}


x86 assembly (clang, -O0):
<sensor_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x28,-0xa(%rbp)
movb   $0x88,-0x9(%rbp)
lea    -0xa(%rbp),%rdi
mov    $0x1,%esi
call   1040 <sensor_i2c_write@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1171 <sensor_config+0x41>
mov    -0xa(%rbp),%al
lea    0xe9b(%rip),%rdi
movsbl %al,%esi
movsbl -0x9(%rbp),%edx
call   1030 <printk@plt>
movb   $0x28,-0xa(%rbp)
lea    -0xa(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <sensor_i2c_read@plt>
mov    -0xa(%rbp),%al
lea    0xe89(%rip),%rdi
movsbl %al,%esi
movsbl -0x9(%rbp),%edx
call   1030 <printk@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sensor_config>:
push   %rbx
sub    $0x10,%rsp
movw   $0x8828,0x6(%rsp)
lea    0x7(%rsp),%rbx
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
call   1040 <sensor_i2c_write@plt>
test   %eax,%eax
jne    116a <sensor_config+0x3a>
movsbl 0x6(%rsp),%esi
movsbl 0x7(%rsp),%edx
lea    0xe9b(%rip),%rdi
call   1030 <printk@plt>
movb   $0x28,0x6(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <sensor_i2c_read@plt>
movsbl 0x6(%rsp),%esi
movsbl 0x7(%rsp),%edx
lea    0xe8d(%rip),%rdi
call   1030 <printk@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"write reg %d value %d ok.\00"
@.str.1 = [23 x i8] c"reg 0x%x value is 0x%x\00"
define void @sensor_config() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
store i8 40, i8* %3
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 -120, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = call i32 @sensor_i2c_write(i8* %5, i32 1)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%11 = load i8, i8* %10
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%13 = load i8, i8* %12
%14 = call i32 @printk(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8 signext %11, i8 signext %13)
br label %15
15: ; preds = %9, %0
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
store i8 40, i8* %16
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @sensor_i2c_read(i8* %18, i32 1)
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%21 = load i8, i8* %20
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%23 = load i8, i8* %22
%24 = call i32 @printk(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %21, i8 signext %23)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"write reg %d value %d ok.\00"
@.str.1 = [23 x i8] c"reg 0x%x value is 0x%x\00"
define void @sensor_config() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
store i8 40, i8* %2
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 -120, i8* %3
%4 = call i32 @sensor_i2c_write(i8* %2, i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i8, i8* %2
%8 = load i8, i8* %3
%9 = call i32 @printk(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8 signext %7, i8 signext %8)
br label %10
10: ; preds = %6, %0
store i8 40, i8* %2
%11 = call i32 @sensor_i2c_read(i8* %3, i32 1)
%12 = load i8, i8* %2
%13 = load i8, i8* %3
%14 = call i32 @printk(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %12, i8 signext %13)
ret void
}