#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 */
typedef int uint8_t;

/* Variables and functions */
int EFAULT;
int bcd2i(int);
int i2c_read_byte(int, int, int *);
int /*<<< orphan*/ isbcd(int);
int ds1307_sanity_check(int file, bool *ok) {
  int res;
  uint8_t reg;
  if (NULL == ok) {
    return -EFAULT;
  }
  if ((res = i2c_read_byte(file, (0x00), &reg)) < 0) {
    return res;
  }
  reg &= (~(1 << 7));
  if ((!isbcd(reg)) || (bcd2i(reg) > 59)) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x01), &reg)) < 0) {
    return res;
  }
  if ((!isbcd(reg)) || (bcd2i(reg) > 59)) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x02), &reg)) < 0) {
    return res;
  }
  bool h12 = (reg & (1 << 6)) ? true : false;
  reg &= (~(1 << 6));
  if (h12) {
    reg &= (~(1 << 5));
    if ((!isbcd(reg)) || (bcd2i(reg) > 12) || (0 == bcd2i(reg))) {
      *ok = false;
      return 0;
    }
  } else {
    if ((!isbcd(reg)) || (bcd2i(reg) > 23)) {
      *ok = false;
      return 0;
    }
  }
  if ((res = i2c_read_byte(file, (0x03), &reg)) < 0) {
    return res;
  }
  if ((!isbcd(reg)) || (bcd2i(reg) > 7) || (0 == bcd2i(reg))) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x04), &reg)) < 0) {
    return res;
  }
  if ((!isbcd(reg)) || (bcd2i(reg) > 31) || (0 == bcd2i(reg))) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x05), &reg)) < 0) {
    return res;
  }
  if ((!isbcd(reg)) || (bcd2i(reg) > 12) || (0 == bcd2i(reg))) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x06), &reg)) < 0) {
    return res;
  }
  if (!isbcd(reg)) {
    *ok = false;
    return 0;
  }
  if ((res = i2c_read_byte(file, (0x06), &reg)) < 0) {
    return res;
  }
  reg &= (~((1 << 7) | (1 << 4) | (1 << 1) | (1 << 0)));
  if (0 != reg) {
    *ok = false;
    return 0;
  }
  *ok = true;
  return 0;
}


x86 assembly (clang, -O0):
<ds1307_sanity_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    115e <ds1307_sanity_check+0x2e>
xor    %eax,%eax
mov    0x2ea4(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1183 <ds1307_sanity_check+0x53>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     11b0 <ds1307_sanity_check+0x80>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0x3b,%eax
jle    11c6 <ds1307_sanity_check+0x96>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ee <ds1307_sanity_check+0xbe>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     1210 <ds1307_sanity_check+0xe0>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0x3b,%eax
jle    1226 <ds1307_sanity_check+0xf6>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    124e <ds1307_sanity_check+0x11e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edx
and    $0x40,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
and    $0xffffffbf,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12d1 <ds1307_sanity_check+0x1a1>
mov    -0x18(%rbp),%eax
and    $0xffffffdf,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     12b6 <ds1307_sanity_check+0x186>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0xc,%eax
jg     12b6 <ds1307_sanity_check+0x186>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    12cc <ds1307_sanity_check+0x19c>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
jmp    130e <ds1307_sanity_check+0x1de>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     12f3 <ds1307_sanity_check+0x1c3>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0x17,%eax
jle    1309 <ds1307_sanity_check+0x1d9>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
jmp    130e <ds1307_sanity_check+0x1de>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1336 <ds1307_sanity_check+0x206>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     136c <ds1307_sanity_check+0x23c>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0x7,%eax
jg     136c <ds1307_sanity_check+0x23c>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1382 <ds1307_sanity_check+0x252>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    13aa <ds1307_sanity_check+0x27a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     13e0 <ds1307_sanity_check+0x2b0>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0x1f,%eax
jg     13e0 <ds1307_sanity_check+0x2b0>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    13f6 <ds1307_sanity_check+0x2c6>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    141e <ds1307_sanity_check+0x2ee>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
je     1454 <ds1307_sanity_check+0x324>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
cmp    $0xc,%eax
jg     1454 <ds1307_sanity_check+0x324>
mov    -0x18(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    146a <ds1307_sanity_check+0x33a>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x6,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1492 <ds1307_sanity_check+0x362>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%edi
call   1030 <isbcd@plt>
cmp    $0x0,%eax
jne    14b9 <ds1307_sanity_check+0x389>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x8(%rbp),%edi
mov    $0x6,%esi
lea    -0x18(%rbp),%rdx
call   1050 <i2c_read_byte@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    14e1 <ds1307_sanity_check+0x3b1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x18(%rbp),%eax
and    $0xffffff6c,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
je     150d <ds1307_sanity_check+0x3dd>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    151e <ds1307_sanity_check+0x3ee>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ds1307_sanity_check>:
push   %rbp
push   %rbx
push   %rax
test   %rsi,%rsi
je     117b <ds1307_sanity_check+0x4b>
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x4(%rsp),%rdx
xor    %esi,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    $0xffffff7f,%edi
and    0x4(%rsp),%edi
mov    %edi,0x4(%rsp)
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0x3c,%eax
jl     118d <ds1307_sanity_check+0x5d>
movl   $0x0,(%rbx)
xor    %eax,%eax
jmp    1186 <ds1307_sanity_check+0x56>
mov    0x2e76(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0x3c,%eax
jge    1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x2,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
mov    %edi,%eax
and    $0xffffffbf,%eax
mov    %eax,0x4(%rsp)
test   $0x40,%dil
jne    1204 <ds1307_sanity_check+0xd4>
mov    %eax,%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0x18,%eax
jge    1171 <ds1307_sanity_check+0x41>
jmp    123b <ds1307_sanity_check+0x10b>
and    $0xffffff9f,%edi
mov    %edi,0x4(%rsp)
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0xc,%eax
jg     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x3,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0x7,%eax
jg     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x4,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0x1f,%eax
jg     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x5,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
cmp    $0xc,%eax
jg     1171 <ds1307_sanity_check+0x41>
mov    0x4(%rsp),%edi
call   1040 <bcd2i@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x6,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
mov    0x4(%rsp),%edi
call   1030 <isbcd@plt>
test   %eax,%eax
je     1171 <ds1307_sanity_check+0x41>
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
mov    $0x6,%esi
call   1050 <i2c_read_byte@plt>
test   %eax,%eax
js     1186 <ds1307_sanity_check+0x56>
andl   $0xffffff6c,0x4(%rsp)
ff
jne    1171 <ds1307_sanity_check+0x41>
movl   $0x1,(%rbx)
jmp    1177 <ds1307_sanity_check+0x47>

LLVM IR (-O0):
@EFAULT = global i32 0
define i32 @ds1307_sanity_check(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%9 = load i32*, i32** %5
%10 = icmp eq i32* null, %9
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @EFAULT
%13 = sub nsw i32 0, %12
store i32 %13, i32* %3
br label %179
14: ; preds = %2
%15 = load i32, i32* %4
%16 = call i32 @i2c_read_byte(i32 %15, i32 0, i32* %7)
store i32 %16, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %179
20: ; preds = %14
%21 = load i32, i32* %7
%22 = and i32 %21, -129
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i32 @isbcd(i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i32, i32* %7
%28 = call i32 @bcd2i(i32 %27)
%29 = icmp sgt i32 %28, 59
br i1 %29, label %30, label %32
30: ; preds = %26, %20
%31 = load i32*, i32** %5
store i32 0, i32* %31
store i32 0, i32* %3
br label %179
32: ; preds = %26
%33 = load i32, i32* %4
%34 = call i32 @i2c_read_byte(i32 %33, i32 1, i32* %7)
store i32 %34, i32* %6
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %6
store i32 %37, i32* %3
br label %179
38: ; preds = %32
%39 = load i32, i32* %7
%40 = call i32 @isbcd(i32 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* %7
%44 = call i32 @bcd2i(i32 %43)
%45 = icmp sgt i32 %44, 59
br i1 %45, label %46, label %48
46: ; preds = %42, %38
%47 = load i32*, i32** %5
store i32 0, i32* %47
store i32 0, i32* %3
br label %179
48: ; preds = %42
%49 = load i32, i32* %4
%50 = call i32 @i2c_read_byte(i32 %49, i32 2, i32* %7)
store i32 %50, i32* %6
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = load i32, i32* %6
store i32 %53, i32* %3
br label %179
54: ; preds = %48
%55 = load i32, i32* %7
%56 = and i32 %55, 64
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 1, i32 0
store i32 %59, i32* %8
%60 = load i32, i32* %7
%61 = and i32 %60, -65
store i32 %61, i32* %7
%62 = load i32, i32* %8
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %81
64: ; preds = %54
%65 = load i32, i32* %7
%66 = and i32 %65, -33
store i32 %66, i32* %7
%67 = load i32, i32* %7
%68 = call i32 @isbcd(i32 %67)
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %78
70: ; preds = %64
%71 = load i32, i32* %7
%72 = call i32 @bcd2i(i32 %71)
%73 = icmp sgt i32 %72, 12
br i1 %73, label %78, label %74
74: ; preds = %70
%75 = load i32, i32* %7
%76 = call i32 @bcd2i(i32 %75)
%77 = icmp eq i32 0, %76
br i1 %77, label %78, label %80
78: ; preds = %74, %70, %64
%79 = load i32*, i32** %5
store i32 0, i32* %79
store i32 0, i32* %3
br label %179
80: ; preds = %74
br label %92
81: ; preds = %54
%82 = load i32, i32* %7
%83 = call i32 @isbcd(i32 %82)
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %81
%86 = load i32, i32* %7
%87 = call i32 @bcd2i(i32 %86)
%88 = icmp sgt i32 %87, 23
br i1 %88, label %89, label %91
89: ; preds = %85, %81
%90 = load i32*, i32** %5
store i32 0, i32* %90
store i32 0, i32* %3
br label %179
91: ; preds = %85
br label %92
92: ; preds = %91, %80
%93 = load i32, i32* %4
%94 = call i32 @i2c_read_byte(i32 %93, i32 3, i32* %7)
store i32 %94, i32* %6
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %92
%97 = load i32, i32* %6
store i32 %97, i32* %3
br label %179
98: ; preds = %92
%99 = load i32, i32* %7
%100 = call i32 @isbcd(i32 %99)
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %110
102: ; preds = %98
%103 = load i32, i32* %7
%104 = call i32 @bcd2i(i32 %103)
%105 = icmp sgt i32 %104, 7
br i1 %105, label %110, label %106
106: ; preds = %102
%107 = load i32, i32* %7
%108 = call i32 @bcd2i(i32 %107)
%109 = icmp eq i32 0, %108
br i1 %109, label %110, label %112
110: ; preds = %106, %102, %98
%111 = load i32*, i32** %5
store i32 0, i32* %111
store i32 0, i32* %3
br label %179
112: ; preds = %106
%113 = load i32, i32* %4
%114 = call i32 @i2c_read_byte(i32 %113, i32 4, i32* %7)
store i32 %114, i32* %6
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %112
%117 = load i32, i32* %6
store i32 %117, i32* %3
br label %179
118: ; preds = %112
%119 = load i32, i32* %7
%120 = call i32 @isbcd(i32 %119)
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %130
122: ; preds = %118
%123 = load i32, i32* %7
%124 = call i32 @bcd2i(i32 %123)
%125 = icmp sgt i32 %124, 31
br i1 %125, label %130, label %126
126: ; preds = %122
%127 = load i32, i32* %7
%128 = call i32 @bcd2i(i32 %127)
%129 = icmp eq i32 0, %128
br i1 %129, label %130, label %132
130: ; preds = %126, %122, %118
%131 = load i32*, i32** %5
store i32 0, i32* %131
store i32 0, i32* %3
br label %179
132: ; preds = %126
%133 = load i32, i32* %4
%134 = call i32 @i2c_read_byte(i32 %133, i32 5, i32* %7)
store i32 %134, i32* %6
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %132
%137 = load i32, i32* %6
store i32 %137, i32* %3
br label %179
138: ; preds = %132
%139 = load i32, i32* %7
%140 = call i32 @isbcd(i32 %139)
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %150
142: ; preds = %138
%143 = load i32, i32* %7
%144 = call i32 @bcd2i(i32 %143)
%145 = icmp sgt i32 %144, 12
br i1 %145, label %150, label %146
146: ; preds = %142
%147 = load i32, i32* %7
%148 = call i32 @bcd2i(i32 %147)
%149 = icmp eq i32 0, %148
br i1 %149, label %150, label %152
150: ; preds = %146, %142, %138
%151 = load i32*, i32** %5
store i32 0, i32* %151
store i32 0, i32* %3
br label %179
152: ; preds = %146
%153 = load i32, i32* %4
%154 = call i32 @i2c_read_byte(i32 %153, i32 6, i32* %7)
store i32 %154, i32* %6
%155 = icmp slt i32 %154, 0
br i1 %155, label %156, label %158
156: ; preds = %152
%157 = load i32, i32* %6
store i32 %157, i32* %3
br label %179
158: ; preds = %152
%159 = load i32, i32* %7
%160 = call i32 @isbcd(i32 %159)
%161 = icmp ne i32 %160, 0
br i1 %161, label %164, label %162
162: ; preds = %158
%163 = load i32*, i32** %5
store i32 0, i32* %163
store i32 0, i32* %3
br label %179
164: ; preds = %158
%165 = load i32, i32* %4
%166 = call i32 @i2c_read_byte(i32 %165, i32 6, i32* %7)
store i32 %166, i32* %6
%167 = icmp slt i32 %166, 0
br i1 %167, label %168, label %170
168: ; preds = %164
%169 = load i32, i32* %6
store i32 %169, i32* %3
br label %179
170: ; preds = %164
%171 = load i32, i32* %7
%172 = and i32 %171, -148
store i32 %172, i32* %7
%173 = load i32, i32* %7
%174 = icmp ne i32 0, %173
br i1 %174, label %175, label %177
175: ; preds = %170
%176 = load i32*, i32** %5
store i32 0, i32* %176
store i32 0, i32* %3
br label %179
177: ; preds = %170
%178 = load i32*, i32** %5
store i32 1, i32* %178
store i32 0, i32* %3
br label %179
179: ; preds = %177, %175, %168, %162, %156, %150, %136, %130, %116, %110, %96, %89, %78, %52, %46, %36, %30, %18, %11
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@EFAULT = global i32 0
define i32 @ds1307_sanity_check(i32 %0, i32* writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32* %1, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @EFAULT
%8 = sub nsw i32 0, %7
br label %128
9: ; preds = %2
%10 = call i32 @i2c_read_byte(i32 %0, i32 0, i32* %3)
%11 = icmp slt i32 %10, 0
br i1 %11, label %128, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = and i32 %13, -129
store i32 %14, i32* %3
%15 = call i32 @isbcd(i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i32 @bcd2i(i32 %18)
%20 = icmp sgt i32 %19, 59
br i1 %20, label %21, label %22
21: ; preds = %17, %12
store i32 0, i32* %1
br label %128
22: ; preds = %17
%23 = call i32 @i2c_read_byte(i32 %0, i32 1, i32* %3)
%24 = icmp slt i32 %23, 0
br i1 %24, label %128, label %25
25: ; preds = %22
%26 = load i32, i32* %3
%27 = call i32 @isbcd(i32 %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %3
%31 = call i32 @bcd2i(i32 %30)
%32 = icmp sgt i32 %31, 59
br i1 %32, label %33, label %34
33: ; preds = %29, %25
store i32 0, i32* %1
br label %128
34: ; preds = %29
%35 = call i32 @i2c_read_byte(i32 %0, i32 2, i32* %3)
%36 = icmp slt i32 %35, 0
br i1 %36, label %128, label %37
37: ; preds = %34
%38 = load i32, i32* %3
%39 = and i32 %38, 64
%40 = icmp eq i32 %39, 0
%41 = and i32 %38, -65
store i32 %41, i32* %3
br i1 %40, label %55, label %42
42: ; preds = %37
%43 = and i32 %38, -97
store i32 %43, i32* %3
%44 = call i32 @isbcd(i32 %43)
%45 = icmp eq i32 %44, 0
br i1 %45, label %54, label %46
46: ; preds = %42
%47 = load i32, i32* %3
%48 = call i32 @bcd2i(i32 %47)
%49 = icmp sgt i32 %48, 12
br i1 %49, label %54, label %50
50: ; preds = %46
%51 = load i32, i32* %3
%52 = call i32 @bcd2i(i32 %51)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %50, %46, %42
store i32 0, i32* %1
br label %128
55: ; preds = %37
%56 = call i32 @isbcd(i32 %41)
%57 = icmp eq i32 %56, 0
br i1 %57, label %62, label %58
58: ; preds = %55
%59 = load i32, i32* %3
%60 = call i32 @bcd2i(i32 %59)
%61 = icmp sgt i32 %60, 23
br i1 %61, label %62, label %63
62: ; preds = %58, %55
store i32 0, i32* %1
br label %128
63: ; preds = %58, %50
%64 = call i32 @i2c_read_byte(i32 %0, i32 3, i32* %3)
%65 = icmp slt i32 %64, 0
br i1 %65, label %128, label %66
66: ; preds = %63
%67 = load i32, i32* %3
%68 = call i32 @isbcd(i32 %67)
%69 = icmp eq i32 %68, 0
br i1 %69, label %78, label %70
70: ; preds = %66
%71 = load i32, i32* %3
%72 = call i32 @bcd2i(i32 %71)
%73 = icmp sgt i32 %72, 7
br i1 %73, label %78, label %74
74: ; preds = %70
%75 = load i32, i32* %3
%76 = call i32 @bcd2i(i32 %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %74, %70, %66
store i32 0, i32* %1
br label %128
79: ; preds = %74
%80 = call i32 @i2c_read_byte(i32 %0, i32 4, i32* %3)
%81 = icmp slt i32 %80, 0
br i1 %81, label %128, label %82
82: ; preds = %79
%83 = load i32, i32* %3
%84 = call i32 @isbcd(i32 %83)
%85 = icmp eq i32 %84, 0
br i1 %85, label %94, label %86
86: ; preds = %82
%87 = load i32, i32* %3
%88 = call i32 @bcd2i(i32 %87)
%89 = icmp sgt i32 %88, 31
br i1 %89, label %94, label %90
90: ; preds = %86
%91 = load i32, i32* %3
%92 = call i32 @bcd2i(i32 %91)
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %90, %86, %82
store i32 0, i32* %1
br label %128
95: ; preds = %90
%96 = call i32 @i2c_read_byte(i32 %0, i32 5, i32* %3)
%97 = icmp slt i32 %96, 0
br i1 %97, label %128, label %98
98: ; preds = %95
%99 = load i32, i32* %3
%100 = call i32 @isbcd(i32 %99)
%101 = icmp eq i32 %100, 0
br i1 %101, label %110, label %102
102: ; preds = %98
%103 = load i32, i32* %3
%104 = call i32 @bcd2i(i32 %103)
%105 = icmp sgt i32 %104, 12
br i1 %105, label %110, label %106
106: ; preds = %102
%107 = load i32, i32* %3
%108 = call i32 @bcd2i(i32 %107)
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %106, %102, %98
store i32 0, i32* %1
br label %128
111: ; preds = %106
%112 = call i32 @i2c_read_byte(i32 %0, i32 6, i32* %3)
%113 = icmp slt i32 %112, 0
br i1 %113, label %128, label %114
114: ; preds = %111
%115 = load i32, i32* %3
%116 = call i32 @isbcd(i32 %115)
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %114
store i32 0, i32* %1
br label %128
119: ; preds = %114
%120 = call i32 @i2c_read_byte(i32 %0, i32 6, i32* %3)
%121 = icmp slt i32 %120, 0
br i1 %121, label %128, label %122
122: ; preds = %119
%123 = load i32, i32* %3
%124 = and i32 %123, -148
store i32 %124, i32* %3
%125 = icmp eq i32 %124, 0
br i1 %125, label %127, label %126
126: ; preds = %122
store i32 0, i32* %1
br label %128
127: ; preds = %122
store i32 1, i32* %1
br label %128
128: ; preds = %54, %62, %78, %94, %110, %118, %126, %127, %63, %79, %95, %111, %119, %34, %22, %9, %33, %21, %6
%129 = phi i32 [ %8, %6 ], [ 0, %21 ], [ 0, %33 ], [ %10, %9 ], [ %23, %22 ], [ %35, %34 ], [ 0, %54 ], [ 0, %78 ], [ 0, %94 ], [ 0, %110 ], [ 0, %126 ], [ 0, %127 ], [ 0, %118 ], [ 0, %62 ], [ %64, %63 ], [ %80, %79 ], [ %96, %95 ], [ %112, %111 ], [ %120, %119 ]
ret i32 %129
}