#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 const *, int /*<<< orphan*/);
int bmp085_i2c_Begin(const char *fileName) {
  int fd;
  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
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1174 <bmp085_i2c_Begin+0x34>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    $0x77,%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11a6 <bmp085_i2c_Begin+0x66>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmp085_i2c_Begin>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
test   %eax,%eax
js     1173 <bmp085_i2c_Begin+0x33>
mov    %eax,%ebx
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x77,%edx
call   1030 <ioctl@plt>
test   %rax,%rax
js     117d <bmp085_i2c_Begin+0x3d>
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):
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp085_i2c_Begin(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_RDWR
%6 = call i32 @open(i8* %4, i32 %5)
store i32 %6, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = load i32, i32* %3
%12 = load i32, i32* @I2C_SLAVE
%13 = call i64 @ioctl(i32 %11, i32 %12, i32 119)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %3
%17 = call i32 @close(i32 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp085_i2c_Begin(i8* nocapture %0) {
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* %0, i32 %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = load i32, i32* @I2C_SLAVE
%9 = tail call i64 @ioctl(i32 %3, i32 %8, i32 119)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @close(i32 %3)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
ret i32 %3
}