#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*/ O_RDWR;
int /*<<< orphan*/ exit(int);
int mpl3115_get_press(int);
int mpl3115_get_temp(int);
int /*<<< orphan*/ mpl3115_init(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sleep(int);
int test() {
  int i2cfd;
  if ((i2cfd = open("/dev/i2c-3", O_RDWR)) < 0) {
    perror("error openning i2c-3!\n");
    exit(1);
  }
  mpl3115_init(i2cfd);
  while (1) {
    sleep(1);
    printf("temp=%d\t alt=%d\n", mpl3115_get_temp(i2cfd),
           mpl3115_get_press(i2cfd));
  }
  return 0;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xe68(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    11bf <test+0x3f>
lea    0xe5b(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%edi
call   1040 <mpl3115_init@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    -0x4(%rbp),%edi
call   1030 <mpl3115_get_temp@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <mpl3115_get_press@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
jmp    11c7 <test+0x47>

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
lea    0xe6c(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
js     11d8 <test+0x58>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <mpl3115_init@plt>
lea    0xe75(%rip),%r14
nopl   (%rax)
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %ebx,%edi
call   1030 <mpl3115_get_temp@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   10a0 <mpl3115_get_press@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <printf@plt>
jmp    11b0 <test+0x30>
lea    0xe2c(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-3\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"error openning i2c-3!\0A\00"
@.str.2 = [17 x i8] c"temp=%d\09 alt=%d\0A\00"
define i32 @test() {
%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 %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = load i32, i32* %1
%10 = call i32 @mpl3115_init(i32 %9)
br label %11
11: ; preds = %8, %11
%12 = call i32 @sleep(i32 1)
%13 = load i32, i32* %1
%14 = call i32 @mpl3115_get_temp(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @mpl3115_get_press(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16)
br label %11
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-3\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"error openning i2c-3!\0A\00"
@.str.2 = [17 x i8] c"temp=%d\09 alt=%d\0A\00"
define i32 @test() {
%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 %7
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @mpl3115_init(i32 %2)
br label %9
9: ; preds = %9, %7
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @mpl3115_get_temp(i32 %2)
%12 = tail call i32 @mpl3115_get_press(i32 %2)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12)
br label %9
}