#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*/ I2C_SLAVE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int bmp085_i2c_Begin() {
  int fd;
  char *fileName = "/dev/i2c-7";
  if ((fd = open(fileName, O_RDWR)) < 0)
    exit(1);
  if (ioctl(fd, I2C_SLAVE, 0x77) < 0) {
    close(fd);
    exit(1);
  }
  return fd;
}


x86 assembly (clang, -O0):
<bmp085_i2c_Begin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    117b <bmp085_i2c_Begin+0x3b>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
mov    $0x77,%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11ad <bmp085_i2c_Begin+0x6d>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmp085_i2c_Begin>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
js     117a <bmp085_i2c_Begin+0x3a>
mov    %eax,%ebx
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x77,%edx
call   1030 <ioctl@plt>
test   %rax,%rax
js     1184 <bmp085_i2c_Begin+0x44>
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-7\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp085_i2c_Begin() {
%1 = alloca i32
%2 = alloca i8*
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* %3, i32 %4)
store i32 %5, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* %1
%11 = load i32, i32* @I2C_SLAVE
%12 = call i64 @ioctl(i32 %10, i32 %11, i32 119)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* %1
%16 = call i32 @close(i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-7\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp085_i2c_Begin() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = load i32, i32* @I2C_SLAVE
%8 = tail call i64 @ioctl(i32 %2, i32 %7, i32 119)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @close(i32 %2)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6
ret i32 %2
}