#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 DMOpenDevFile();
scalar_t__ DMPingSensors(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  printf("Opening the i2c sensor device!\n\n");
  int devFile = DMOpenDevFile();
  if (devFile < 0) {
    printf("Failed to open the i2c bus");
    return 1;
  }
  if (DMPingSensors(devFile) < 0) {
    if (1) {
      printf("Could not ping sensors");
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <DMOpenDevFile@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    117e <main+0x4e>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <main+0x7f>
mov    -0x14(%rbp),%edi
call   1050 <DMPingSensors@plt>
cmp    $0x0,%rax
jge    11a8 <main+0x78>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <main+0x7f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <DMOpenDevFile@plt>
test   %eax,%eax
js     116f <main+0x2f>
mov    %eax,%edi
call   1060 <DMPingSensors@plt>
test   %rax,%rax
jns    1180 <main+0x40>
lea    0xeae(%rip),%rdi
jmp    1176 <main+0x36>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Opening the i2c sensor device!\0A\0A\00"
@.str.1 = [27 x i8] c"Failed to open the i2c bus\00"
@.str.2 = [23 x i8] c"Could not ping sensors\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @DMOpenDevFile()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %20
13: ; preds = %2
%14 = load i32, i32* %6
%15 = call i64 @DMPingSensors(i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %20
19: ; preds = %13
store i32 0, i32* %3
br label %20
20: ; preds = %19, %17, %11
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"Failed to open the i2c bus\00"
@.str.2 = [23 x i8] c"Could not ping sensors\00"
@str = [32 x i8] c"Opening the i2c sensor device!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @DMOpenDevFile()
%5 = icmp slt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 @DMPingSensors(i32 %4)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6, %2
%10 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %6 ]
%11 = tail call i32 @printf(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %9, %6
%13 = phi i32 [ 0, %6 ], [ 1, %9 ]
ret i32 %13
}