#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 bcd2i(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int,
                           char const *, ...);
int i2c_read_byte(int, int, int *);
int /*<<< orphan*/ stdout;
int weekday2c(int, char const **);
int ds1307_print_time(int file) {
  int res;
  uint8_t sec;
  bool hlt;
  if ((res = i2c_read_byte(file, (0x00), &sec)) < 0) {
    return res;
  }
  hlt = (sec & (1 << 7)) ? true : false;
  sec = bcd2i(sec & (~(1 << 7)));
  uint8_t min;
  if ((res = i2c_read_byte(file, (0x01), &min)) < 0) {
    return res;
  }
  min = bcd2i(min);
  uint8_t hrs;
  bool h12;
  bool hpm;
  if ((res = i2c_read_byte(file, (0x02), &hrs)) < 0) {
    return res;
  }
  h12 = (hrs & (1 << 6)) ? true : false;
  hpm = (hrs & (1 << 5)) ? true : false;
  if (h12) {
    hrs = bcd2i(hrs & (~((1 << 6) | (1 << 5))));
  } else {
    hrs = bcd2i(hrs & (~(1 << 6)));
  }
  uint8_t dow;
  const char *dows;
  if ((res = i2c_read_byte(file, (0x03), &dow)) < 0) {
    return res;
  }
  if ((res = weekday2c(dow, &dows)) < 0) {
    return res;
  }
  uint8_t day;
  if ((res = i2c_read_byte(file, (0x04), &day)) < 0) {
    return res;
  }
  day = bcd2i(day);
  uint8_t mon;
  if ((res = i2c_read_byte(file, (0x05), &mon)) < 0) {
    return res;
  }
  mon = bcd2i(mon);
  uint8_t yrs;
  if ((res = i2c_read_byte(file, (0x06), &yrs)) < 0) {
    return res;
  }
  yrs = bcd2i(yrs);
  uint8_t ctl;
  if ((res = i2c_read_byte(file, (0x07), &ctl)) < 0) {
    return res;
  }
  if (h12) {
    fprintf(stdout, "20%02d-%02d-%02d %s %s %02d:%02d:%02d %s 12H\n", yrs, mon,
            day, dows, hpm ? "PM" : "AM", hrs, min, sec,
            hlt ? "HALTED" : "RUNNING");
  } else {
    fprintf(stdout, "20%02d-%02d-%02d %s    %02d:%02d:%02d %s 24H\n", yrs, mon,
            day, dows, hrs, min, sec, hlt ? "HALTED" : "RUNNING");
  }
  return 0;
}


x86 assembly (clang, -O0):
<ds1307_print_time>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %edi,-0x20(%rbp)
mov    -0x20(%rbp),%edi
xor    %esi,%esi
lea    -0x28(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1175 <ds1307_print_time+0x35>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x28(%rbp),%edx
and    $0x80,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
and    $0xffffff7f,%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x1,%esi
lea    -0x30(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11c7 <ds1307_print_time+0x87>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x30(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x2,%esi
lea    -0x34(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11fa <ds1307_print_time+0xba>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x34(%rbp),%edx
and    $0x40,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edx
and    $0x20,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1243 <ds1307_print_time+0x103>
mov    -0x34(%rbp),%edi
and    $0xffffff9f,%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x34(%rbp)
jmp    1251 <ds1307_print_time+0x111>
mov    -0x34(%rbp),%edi
and    $0xffffffbf,%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x3,%esi
lea    -0x40(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1279 <ds1307_print_time+0x139>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x40(%rbp),%edi
lea    -0x48(%rbp),%rsi
call   1030 <weekday2c@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    129c <ds1307_print_time+0x15c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x20(%rbp),%edi
mov    $0x4,%esi
lea    -0x4c(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12c4 <ds1307_print_time+0x184>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x4c(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x5,%esi
lea    -0x50(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12f7 <ds1307_print_time+0x1b7>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x50(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x50(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x6,%esi
lea    -0x54(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    132a <ds1307_print_time+0x1ea>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
mov    -0x54(%rbp),%edi
call   1040 <bcd2i@plt>
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x7,%esi
lea    -0x58(%rbp),%rdx
call   1060 <i2c_read_byte@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    135d <ds1307_print_time+0x21d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1448 <ds1307_print_time+0x308>
cmpl   $0x0,-0x38(%rbp)
je     13e5 <ds1307_print_time+0x2a5>
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x48(%rbp),%r9
mov    -0x3c(%rbp),%esi
lea    0xca9(%rip),%r14
lea    0xc9f(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r14
mov    -0x34(%rbp),%ebx
mov    -0x30(%rbp),%r11d
mov    -0x28(%rbp),%r10d
mov    -0x2c(%rbp),%r15d
lea    0xc8f(%rip),%rax
lea    0xc81(%rip),%rsi
cmp    $0x0,%r15d
cmovne %rsi,%rax
lea    0xc3e(%rip),%rsi
mov    %r14,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1441 <ds1307_print_time+0x301>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x48(%rbp),%r9
mov    -0x34(%rbp),%ebx
mov    -0x30(%rbp),%r11d
mov    -0x28(%rbp),%r10d
mov    -0x2c(%rbp),%r14d
lea    0xc29(%rip),%rax
lea    0xc1b(%rip),%rsi
cmp    $0x0,%r14d
cmovne %rsi,%rax
lea    0xc1b(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ds1307_print_time>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
lea    0x14(%rsp),%rdx
xor    %esi,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x14(%rsp),%r14d
mov    %r14d,%edi
and    $0xffffff7f,%edi
call   1040 <bcd2i@plt>
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x10(%rsp),%edi
call   1040 <bcd2i@plt>
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
mov    $0x2,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0xc(%rsp),%r15d
xor    %edi,%edi
test   $0x40,%r15b
sete   %dil
shl    $0x5,%edi
or     $0xffffff9f,%edi
and    %r15d,%edi
call   1040 <bcd2i@plt>
mov    %eax,0xc(%rsp)
lea    0x24(%rsp),%rdx
mov    %ebx,%edi
mov    $0x3,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x24(%rsp),%edi
lea    0x28(%rsp),%rsi
call   1030 <weekday2c@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
mov    $0x4,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x20(%rsp),%edi
call   1040 <bcd2i@plt>
mov    %eax,0x20(%rsp)
lea    0x1c(%rsp),%rdx
mov    %ebx,%edi
mov    $0x5,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x1c(%rsp),%edi
call   1040 <bcd2i@plt>
mov    %eax,0x1c(%rsp)
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
mov    $0x6,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x18(%rsp),%edi
call   1040 <bcd2i@plt>
mov    %eax,0x18(%rsp)
lea    0x34(%rsp),%rdx
mov    %ebx,%edi
mov    $0x7,%esi
call   1060 <i2c_read_byte@plt>
test   %eax,%eax
js     12f0 <ds1307_print_time+0x1b0>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x20(%rsp),%r8d
mov    0x28(%rsp),%r9
test   $0x40,%r15b
jne    12ff <ds1307_print_time+0x1bf>
test   $0x80,%r14b
mov    0xc(%rsp),%r10d
mov    0x10(%rsp),%r11d
mov    0x14(%rsp),%r14d
lea    0xd73(%rip),%rax
lea    0xd65(%rip),%rbx
cmove  %rax,%rbx
lea    0xd69(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
push   %rbx
push   %r14
push   %r11
push   %r10
call   1050 <fprintf@plt>
add    $0x20,%rsp
jmp    12f2 <ds1307_print_time+0x1b2>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
test   $0x20,%r15b
lea    0xd27(%rip),%rax
lea    0xd1d(%rip),%r15
cmove  %rax,%r15
test   $0x80,%r14b
mov    0xc(%rsp),%r10d
mov    0x10(%rsp),%r11d
mov    0x14(%rsp),%r14d
lea    0xd0c(%rip),%rax
lea    0xcfe(%rip),%rbx
cmove  %rax,%rbx
sub    $0x8,%rsp
lea    0xcbb(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
push   %rbx
push   %r14
push   %r11
push   %r10
push   %r15
call   1050 <fprintf@plt>
add    $0x30,%rsp
jmp    12f2 <ds1307_print_time+0x1b2>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [46 x i8] c"20%02d-%02d-%02d %s %s %02d:%02d:%02d %s 12H\0A\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [7 x i8] c"HALTED\00"
@.str.4 = [8 x i8] c"RUNNING\00"
@.str.5 = [46 x i8] c"20%02d-%02d-%02d %s %02d:%02d:%02d %s 24H\0A\00"
define i32 @ds1307_print_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @i2c_read_byte(i32 %17, i32 0, i32* %5)
store i32 %18, i32* %4
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %143
22: ; preds = %1
%23 = load i32, i32* %5
%24 = and i32 %23, 128
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 1, i32 0
store i32 %27, i32* %6
%28 = load i32, i32* %5
%29 = and i32 %28, -129
%30 = call i32 @bcd2i(i32 %29)
store i32 %30, i32* %5
%31 = load i32, i32* %3
%32 = call i32 @i2c_read_byte(i32 %31, i32 1, i32* %7)
store i32 %32, i32* %4
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %22
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %143
36: ; preds = %22
%37 = load i32, i32* %7
%38 = call i32 @bcd2i(i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %3
%40 = call i32 @i2c_read_byte(i32 %39, i32 2, i32* %8)
store i32 %40, i32* %4
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %4
store i32 %43, i32* %2
br label %143
44: ; preds = %36
%45 = load i32, i32* %8
%46 = and i32 %45, 64
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 1, i32 0
store i32 %49, i32* %9
%50 = load i32, i32* %8
%51 = and i32 %50, 32
%52 = icmp ne i32 %51, 0
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 1, i32 0
store i32 %54, i32* %10
%55 = load i32, i32* %9
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %44
%58 = load i32, i32* %8
%59 = and i32 %58, -97
%60 = call i32 @bcd2i(i32 %59)
store i32 %60, i32* %8
br label %65
61: ; preds = %44
%62 = load i32, i32* %8
%63 = and i32 %62, -65
%64 = call i32 @bcd2i(i32 %63)
store i32 %64, i32* %8
br label %65
65: ; preds = %61, %57
%66 = load i32, i32* %3
%67 = call i32 @i2c_read_byte(i32 %66, i32 3, i32* %11)
store i32 %67, i32* %4
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = load i32, i32* %4
store i32 %70, i32* %2
br label %143
71: ; preds = %65
%72 = load i32, i32* %11
%73 = call i32 @weekday2c(i32 %72, i8** %12)
store i32 %73, i32* %4
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = load i32, i32* %4
store i32 %76, i32* %2
br label %143
77: ; preds = %71
%78 = load i32, i32* %3
%79 = call i32 @i2c_read_byte(i32 %78, i32 4, i32* %13)
store i32 %79, i32* %4
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = load i32, i32* %4
store i32 %82, i32* %2
br label %143
83: ; preds = %77
%84 = load i32, i32* %13
%85 = call i32 @bcd2i(i32 %84)
store i32 %85, i32* %13
%86 = load i32, i32* %3
%87 = call i32 @i2c_read_byte(i32 %86, i32 5, i32* %14)
store i32 %87, i32* %4
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = load i32, i32* %4
store i32 %90, i32* %2
br label %143
91: ; preds = %83
%92 = load i32, i32* %14
%93 = call i32 @bcd2i(i32 %92)
store i32 %93, i32* %14
%94 = load i32, i32* %3
%95 = call i32 @i2c_read_byte(i32 %94, i32 6, i32* %15)
store i32 %95, i32* %4
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %91
%98 = load i32, i32* %4
store i32 %98, i32* %2
br label %143
99: ; preds = %91
%100 = load i32, i32* %15
%101 = call i32 @bcd2i(i32 %100)
store i32 %101, i32* %15
%102 = load i32, i32* %3
%103 = call i32 @i2c_read_byte(i32 %102, i32 7, i32* %16)
store i32 %103, i32* %4
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %99
%106 = load i32, i32* %4
store i32 %106, i32* %2
br label %143
107: ; preds = %99
%108 = load i32, i32* %9
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %128
110: ; preds = %107
%111 = load i32, i32* @stdout
%112 = load i32, i32* %15
%113 = load i32, i32* %14
%114 = load i32, i32* %13
%115 = load i8*, i8** %12
%116 = load i32, i32* %10
%117 = icmp ne i32 %116, 0
%118 = zext i1 %117 to i64
%119 = select i1 %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%120 = load i32, i32* %8
%121 = load i32, i32* %7
%122 = load i32, i32* %5
%123 = load i32, i32* %6
%124 = icmp ne i32 %123, 0
%125 = zext i1 %124 to i64
%126 = select i1 %124, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%127 = call i32 (i32, i8*, i32, i32, i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %112, i32 %113, i32 %114, i8* %115, i8* %119, i32 %120, i32 %121, i32 %122, i8* %126)
br label %142
128: ; preds = %107
%129 = load i32, i32* @stdout
%130 = load i32, i32* %15
%131 = load i32, i32* %14
%132 = load i32, i32* %13
%133 = load i8*, i8** %12
%134 = load i32, i32* %8
%135 = load i32, i32* %7
%136 = load i32, i32* %5
%137 = load i32, i32* %6
%138 = icmp ne i32 %137, 0
%139 = zext i1 %138 to i64
%140 = select i1 %138, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%141 = call i32 (i32, i8*, i32, i32, i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %130, i32 %131, i32 %132, i8* %133, i32 %134, i32 %135, i32 %136, i8* %140)
br label %142
142: ; preds = %128, %110
store i32 0, i32* %2
br label %143
143: ; preds = %142, %105, %97, %89, %81, %75, %69, %42, %34, %20
%144 = load i32, i32* %2
ret i32 %144
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [46 x i8] c"20%02d-%02d-%02d %s %s %02d:%02d:%02d %s 12H\0A\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
@.str.3 = [7 x i8] c"HALTED\00"
@.str.4 = [8 x i8] c"RUNNING\00"
@.str.5 = [46 x i8] c"20%02d-%02d-%02d %s %02d:%02d:%02d %s 24H\0A\00"
define i32 @ds1307_print_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %2 to i8*
%12 = call i32 @i2c_read_byte(i32 %0, i32 0, i32* %2)
%13 = icmp slt i32 %12, 0
br i1 %13, label %101, label %14
14: ; preds = %1
%15 = load i32, i32* %2
%16 = and i32 %15, 128
%17 = icmp eq i32 %16, 0
%18 = and i32 %15, -129
%19 = call i32 @bcd2i(i32 %18)
store i32 %19, i32* %2
%20 = bitcast i32* %3 to i8*
%21 = call i32 @i2c_read_byte(i32 %0, i32 1, i32* %3)
%22 = icmp slt i32 %21, 0
br i1 %22, label %99, label %23
23: ; preds = %14
%24 = load i32, i32* %3
%25 = call i32 @bcd2i(i32 %24)
store i32 %25, i32* %3
%26 = bitcast i32* %4 to i8*
%27 = call i32 @i2c_read_byte(i32 %0, i32 2, i32* %4)
%28 = icmp slt i32 %27, 0
br i1 %28, label %97, label %29
29: ; preds = %23
%30 = load i32, i32* %4
%31 = and i32 %30, 64
%32 = icmp eq i32 %31, 0
%33 = and i32 %30, 32
%34 = icmp eq i32 %33, 0
%35 = select i1 %32, i32 -65, i32 -97
%36 = and i32 %30, %35
%37 = call i32 @bcd2i(i32 %36)
store i32 %37, i32* %4
%38 = bitcast i32* %5 to i8*
%39 = bitcast i8** %6 to i8*
%40 = call i32 @i2c_read_byte(i32 %0, i32 3, i32* %5)
%41 = icmp slt i32 %40, 0
br i1 %41, label %95, label %42
42: ; preds = %29
%43 = load i32, i32* %5
%44 = call i32 @weekday2c(i32 %43, i8** %6)
%45 = icmp slt i32 %44, 0
br i1 %45, label %95, label %46
46: ; preds = %42
%47 = bitcast i32* %7 to i8*
%48 = call i32 @i2c_read_byte(i32 %0, i32 4, i32* %7)
%49 = icmp slt i32 %48, 0
br i1 %49, label %93, label %50
50: ; preds = %46
%51 = load i32, i32* %7
%52 = call i32 @bcd2i(i32 %51)
store i32 %52, i32* %7
%53 = bitcast i32* %8 to i8*
%54 = call i32 @i2c_read_byte(i32 %0, i32 5, i32* %8)
%55 = icmp slt i32 %54, 0
br i1 %55, label %91, label %56
56: ; preds = %50
%57 = load i32, i32* %8
%58 = call i32 @bcd2i(i32 %57)
store i32 %58, i32* %8
%59 = bitcast i32* %9 to i8*
%60 = call i32 @i2c_read_byte(i32 %0, i32 6, i32* %9)
%61 = icmp slt i32 %60, 0
br i1 %61, label %89, label %62
62: ; preds = %56
%63 = load i32, i32* %9
%64 = call i32 @bcd2i(i32 %63)
store i32 %64, i32* %9
%65 = bitcast i32* %10 to i8*
%66 = call i32 @i2c_read_byte(i32 %0, i32 7, i32* %10)
%67 = icmp slt i32 %66, 0
br i1 %67, label %87, label %68
68: ; preds = %62
%69 = load i32, i32* @stdout
%70 = load i32, i32* %9
%71 = load i32, i32* %8
%72 = load i32, i32* %7
%73 = load i8*, i8** %6
br i1 %32, label %81, label %74
74: ; preds = %68
%75 = select i1 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%76 = load i32, i32* %4
%77 = load i32, i32* %3
%78 = load i32, i32* %2
%79 = select i1 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%80 = call i32 (i32, i8*, i32, i32, i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %70, i32 %71, i32 %72, i8* %73, i8* %75, i32 %76, i32 %77, i32 %78, i8* %79)
br label %87
81: ; preds = %68
%82 = load i32, i32* %4
%83 = load i32, i32* %3
%84 = load i32, i32* %2
%85 = select i1 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%86 = call i32 (i32, i8*, i32, i32, i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %70, i32 %71, i32 %72, i8* %73, i32 %82, i32 %83, i32 %84, i8* %85)
br label %87
87: ; preds = %74, %81, %62
%88 = phi i32 [ %66, %62 ], [ 0, %81 ], [ 0, %74 ]
br label %89
89: ; preds = %56, %87
%90 = phi i32 [ %88, %87 ], [ %60, %56 ]
br label %91
91: ; preds = %50, %89
%92 = phi i32 [ %90, %89 ], [ %54, %50 ]
br label %93
93: ; preds = %46, %91
%94 = phi i32 [ %92, %91 ], [ %48, %46 ]
br label %95
95: ; preds = %42, %29, %93
%96 = phi i32 [ %94, %93 ], [ %40, %29 ], [ %44, %42 ]
br label %97
97: ; preds = %23, %95
%98 = phi i32 [ %96, %95 ], [ %27, %23 ]
br label %99
99: ; preds = %14, %97
%100 = phi i32 [ %98, %97 ], [ %21, %14 ]
br label %101
101: ; preds = %1, %99
%102 = phi i32 [ %100, %99 ], [ %12, %1 ]
ret i32 %102
}