#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*/ printf(char *);
scalar_t__ rc_i2c_get_in_use_state(int);
int /*<<< orphan*/ rc_i2c_release_bus(int);
scalar_t__ rc_i2c_set_device_address(int, int);
scalar_t__ rc_i2c_write_byte(int, int, int);
int rc_power_off_barometer() {
  if (rc_i2c_get_in_use_state(2)) {
    printf("i2c bus claimed by another process\n");
    printf("Continuing with rc_initialize_barometer() anyway.\n");
  }
  if (rc_i2c_set_device_address(2, 0x76) < 0) {
    printf("ERROR: failed to set the i2c device address\n");
    rc_i2c_release_bus(2);
    return -1;
  }
  if (rc_i2c_write_byte(2, (0xF4), 0x00) < 0) {
    printf("ERROR: cannot write bmp_mode_register\n");
    printf("aborting rc_power_off_barometer()\n");
    rc_i2c_release_bus(2);
    return -1;
  }
  rc_i2c_release_bus(2);
  return 0;
}


x86 assembly (clang, -O0):
<rc_power_off_barometer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
call   1030 <rc_i2c_get_in_use_state@plt>
cmp    $0x0,%rax
je     1184 <rc_power_off_barometer+0x34>
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
mov    $0x76,%esi
call   1060 <rc_i2c_set_device_address@plt>
cmp    $0x0,%rax
jge    11bf <rc_power_off_barometer+0x6f>
lea    0xeb3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   1070 <rc_i2c_release_bus@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <rc_power_off_barometer+0xc9>
mov    $0x2,%edi
mov    $0xf4,%esi
xor    %edx,%edx
call   1040 <rc_i2c_write_byte@plt>
cmp    $0x0,%rax
jge    1208 <rc_power_off_barometer+0xb8>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   1070 <rc_i2c_release_bus@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <rc_power_off_barometer+0xc9>
mov    $0x2,%edi
call   1070 <rc_i2c_release_bus@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_power_off_barometer>:
push   %rbx
mov    $0x2,%edi
call   1040 <rc_i2c_get_in_use_state@plt>
test   %rax,%rax
je     1178 <rc_power_off_barometer+0x28>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
mov    $0x76,%esi
call   1060 <rc_i2c_set_device_address@plt>
test   %rax,%rax
js     11b9 <rc_power_off_barometer+0x69>
xor    %ebx,%ebx
mov    $0x2,%edi
mov    $0xf4,%esi
xor    %edx,%edx
call   1050 <rc_i2c_write_byte@plt>
test   %rax,%rax
jns    11ca <rc_power_off_barometer+0x7a>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
jmp    11c0 <rc_power_off_barometer+0x70>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    $0x2,%edi
call   1070 <rc_i2c_release_bus@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"i2c bus claimed by another process\0A\00"
@.str.1 = [51 x i8] c"Continuing with rc_initialize_barometer() anyway.\0A\00"
@.str.2 = [45 x i8] c"ERROR: failed to set the i2c device address\0A\00"
@.str.3 = [39 x i8] c"ERROR: cannot write bmp_mode_register\0A\00"
@.str.4 = [35 x i8] c"aborting rc_power_off_barometer()\0A\00"
define i32 @rc_power_off_barometer() {
%1 = alloca i32
%2 = call i64 @rc_i2c_get_in_use_state(i32 2)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %4, %0
%8 = call i64 @rc_i2c_set_device_address(i32 2, i32 118)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @rc_i2c_release_bus(i32 2)
store i32 -1, i32* %1
br label %22
13: ; preds = %7
%14 = call i64 @rc_i2c_write_byte(i32 2, i32 244, i32 0)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @rc_i2c_release_bus(i32 2)
store i32 -1, i32* %1
br label %22
20: ; preds = %13
%21 = call i32 @rc_i2c_release_bus(i32 2)
store i32 0, i32* %1
br label %22
22: ; preds = %20, %16, %10
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@str = [38 x i8] c"ERROR: cannot write bmp_mode_register\00"
@str.5 = [34 x i8] c"aborting rc_power_off_barometer()\00"
@str.6 = [44 x i8] c"ERROR: failed to set the i2c device address\00"
@str.7 = [35 x i8] c"i2c bus claimed by another process\00"
@str.8 = [50 x i8] c"Continuing with rc_initialize_barometer() anyway.\00"
define i32 @rc_power_off_barometer() {
%1 = tail call i64 @rc_i2c_get_in_use_state(i32 2)
%2 = icmp eq i64 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.8, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = tail call i64 @rc_i2c_set_device_address(i32 2, i32 118)
%8 = icmp slt i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i64 @rc_i2c_write_byte(i32 2, i32 244, i32 0)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %6, %12
%15 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0), %6 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %14, %9
%18 = phi i32 [ 0, %9 ], [ -1, %14 ]
%19 = tail call i32 @rc_i2c_release_bus(i32 2)
ret i32 %18
}