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


x86 assembly (clang, -O0):
<bmp180_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    1173 <bmp180_open+0x33>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
mov    $0x77,%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11a5 <bmp180_open+0x65>
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):
<bmp180_open>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
js     117a <bmp180_open+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 <bmp180_open+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-1\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp180_open() {
%1 = alloca i32
%2 = load i32, i32* @O_RDWR
%3 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %2)
store i32 %3, i32* %1
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = load i32, i32* %1
%9 = load i32, i32* @I2C_SLAVE
%10 = call i64 @ioctl(i32 %8, i32 %9, i32 119)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* %1
%14 = call i32 @close(i32 %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %7
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
define i32 @bmp180_open() {
%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
}