#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*/ DS1302(int, int);
int /*<<< orphan*/ Idle_1302();
void Write_1302_Data(unsigned char *TimeBuffer) {
  unsigned char Cmd_Byte;
  unsigned char databyte;
  unsigned char shifter;
  unsigned int i, j;
  DS1302(1, 0);
  DS1302(4, 0);
  DS1302(2, 1);
  Cmd_Byte = 0xbe;
  shifter = 0x01;
  for (i = 0; i < 8; i++) {
    if (shifter & Cmd_Byte)
      DS1302(4, 1);
    else
      DS1302(4, 0);
    DS1302(1, 1);
    shifter = shifter << 1;
    DS1302(1, 0);
  }
  for (i = 0; i < 8; i++) {
    shifter = 0x01;
    databyte = TimeBuffer[i];
    for (j = 0; j < 8; j++) {
      if (shifter & databyte)
        DS1302(4, 1);
      else
        DS1302(4, 0);
      DS1302(1, 1);
      shifter = shifter << 1;
      DS1302(1, 0);
    }
  }
  Idle_1302();
  return;
}


x86 assembly (clang, -O0):
<Write_1302_Data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
movb   $0xbe,-0x9(%rbp)
movb   $0x1,-0xb(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jae    11cf <Write_1302_Data+0xaf>
movzbl -0xb(%rbp),%eax
movzbl -0x9(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1193 <Write_1302_Data+0x73>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
jmp    119f <Write_1302_Data+0x7f>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <DS1302@plt>
movzbl -0xb(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0xb(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <Write_1302_Data+0x42>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jae    1278 <Write_1302_Data+0x158>
movb   $0x1,-0xb(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xa(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jae    1265 <Write_1302_Data+0x145>
movzbl -0xb(%rbp),%eax
movzbl -0xa(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1229 <Write_1302_Data+0x109>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
jmp    1235 <Write_1302_Data+0x115>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <DS1302@plt>
movzbl -0xb(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0xb(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f8 <Write_1302_Data+0xd8>
jmp    126a <Write_1302_Data+0x14a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d6 <Write_1302_Data+0xb6>
mov    $0x0,%al
call   1030 <Idle_1302@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Write_1302_Data>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%ebp
mov    %ebp,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    %esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
mov    %ebp,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
shr    $0x7,%ebp
mov    $0x4,%edi
mov    %ebp,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <DS1302@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <DS1302@plt>
add    $0x1,%rbx
cmp    $0x8,%rbx
jne    12a0 <Write_1302_Data+0x180>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <Idle_1302@plt>

LLVM IR (-O0):
define void @Write_1302_Data(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i32 @DS1302(i32 1, i32 0)
%9 = call i32 @DS1302(i32 4, i32 0)
%10 = call i32 @DS1302(i32 2, i32 1)
store i8 -66, i8* %3
store i8 1, i8* %5
store i32 0, i32* %6
br label %11
11: ; preds = %32, %1
%12 = load i32, i32* %6
%13 = icmp ult i32 %12, 8
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = load i8, i8* %5
%16 = zext i8 %15 to i32
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = and i32 %16, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @DS1302(i32 4, i32 1)
br label %25
23: ; preds = %14
%24 = call i32 @DS1302(i32 4, i32 0)
br label %25
25: ; preds = %23, %21
%26 = call i32 @DS1302(i32 1, i32 1)
%27 = load i8, i8* %5
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 1
%30 = trunc i32 %29 to i8
store i8 %30, i8* %5
%31 = call i32 @DS1302(i32 1, i32 0)
br label %32
32: ; preds = %25
%33 = load i32, i32* %6
%34 = add i32 %33, 1
store i32 %34, i32* %6
br label %11
35: ; preds = %11
store i32 0, i32* %6
br label %36
36: ; preds = %70, %35
%37 = load i32, i32* %6
%38 = icmp ult i32 %37, 8
br i1 %38, label %39, label %73
39: ; preds = %36
store i8 1, i8* %5
%40 = load i8*, i8** %2
%41 = load i32, i32* %6
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
store i8 %44, i8* %4
store i32 0, i32* %7
br label %45
45: ; preds = %66, %39
%46 = load i32, i32* %7
%47 = icmp ult i32 %46, 8
br i1 %47, label %48, label %69
48: ; preds = %45
%49 = load i8, i8* %5
%50 = zext i8 %49 to i32
%51 = load i8, i8* %4
%52 = zext i8 %51 to i32
%53 = and i32 %50, %52
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 @DS1302(i32 4, i32 1)
br label %59
57: ; preds = %48
%58 = call i32 @DS1302(i32 4, i32 0)
br label %59
59: ; preds = %57, %55
%60 = call i32 @DS1302(i32 1, i32 1)
%61 = load i8, i8* %5
%62 = zext i8 %61 to i32
%63 = shl i32 %62, 1
%64 = trunc i32 %63 to i8
store i8 %64, i8* %5
%65 = call i32 @DS1302(i32 1, i32 0)
br label %66
66: ; preds = %59
%67 = load i32, i32* %7
%68 = add i32 %67, 1
store i32 %68, i32* %7
br label %45
69: ; preds = %45
br label %70
70: ; preds = %69
%71 = load i32, i32* %6
%72 = add i32 %71, 1
store i32 %72, i32* %6
br label %36
73: ; preds = %36
%74 = call i32 (...) @Idle_1302()
ret void
}

LLVM IR (-O2):
define void @Write_1302_Data(i8* nocapture %0) {
%2 = tail call i32 @DS1302(i32 1, i32 0)
%3 = tail call i32 @DS1302(i32 4, i32 0)
%4 = tail call i32 @DS1302(i32 2, i32 1)
%5 = tail call i32 @DS1302(i32 4, i32 0)
%6 = tail call i32 @DS1302(i32 1, i32 1)
%7 = tail call i32 @DS1302(i32 1, i32 0)
%8 = tail call i32 @DS1302(i32 4, i32 1)
%9 = tail call i32 @DS1302(i32 1, i32 1)
%10 = tail call i32 @DS1302(i32 1, i32 0)
%11 = tail call i32 @DS1302(i32 4, i32 1)
%12 = tail call i32 @DS1302(i32 1, i32 1)
%13 = tail call i32 @DS1302(i32 1, i32 0)
%14 = tail call i32 @DS1302(i32 4, i32 1)
%15 = tail call i32 @DS1302(i32 1, i32 1)
%16 = tail call i32 @DS1302(i32 1, i32 0)
%17 = tail call i32 @DS1302(i32 4, i32 1)
%18 = tail call i32 @DS1302(i32 1, i32 1)
%19 = tail call i32 @DS1302(i32 1, i32 0)
%20 = tail call i32 @DS1302(i32 4, i32 1)
%21 = tail call i32 @DS1302(i32 1, i32 1)
%22 = tail call i32 @DS1302(i32 1, i32 0)
%23 = tail call i32 @DS1302(i32 4, i32 0)
%24 = tail call i32 @DS1302(i32 1, i32 1)
%25 = tail call i32 @DS1302(i32 1, i32 0)
%26 = tail call i32 @DS1302(i32 4, i32 1)
%27 = tail call i32 @DS1302(i32 1, i32 1)
%28 = tail call i32 @DS1302(i32 1, i32 0)
br label %29
29: ; preds = %1, %29
%30 = phi i64 [ %72, %29 ], [ 0, %1 ]
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = and i32 %33, 1
%35 = tail call i32 @DS1302(i32 4, i32 %34)
%36 = tail call i32 @DS1302(i32 1, i32 1)
%37 = tail call i32 @DS1302(i32 1, i32 0)
%38 = lshr i32 %33, 1
%39 = and i32 %38, 1
%40 = tail call i32 @DS1302(i32 4, i32 %39)
%41 = tail call i32 @DS1302(i32 1, i32 1)
%42 = tail call i32 @DS1302(i32 1, i32 0)
%43 = lshr i32 %33, 2
%44 = and i32 %43, 1
%45 = tail call i32 @DS1302(i32 4, i32 %44)
%46 = tail call i32 @DS1302(i32 1, i32 1)
%47 = tail call i32 @DS1302(i32 1, i32 0)
%48 = lshr i32 %33, 3
%49 = and i32 %48, 1
%50 = tail call i32 @DS1302(i32 4, i32 %49)
%51 = tail call i32 @DS1302(i32 1, i32 1)
%52 = tail call i32 @DS1302(i32 1, i32 0)
%53 = lshr i32 %33, 4
%54 = and i32 %53, 1
%55 = tail call i32 @DS1302(i32 4, i32 %54)
%56 = tail call i32 @DS1302(i32 1, i32 1)
%57 = tail call i32 @DS1302(i32 1, i32 0)
%58 = lshr i32 %33, 5
%59 = and i32 %58, 1
%60 = tail call i32 @DS1302(i32 4, i32 %59)
%61 = tail call i32 @DS1302(i32 1, i32 1)
%62 = tail call i32 @DS1302(i32 1, i32 0)
%63 = lshr i32 %33, 6
%64 = and i32 %63, 1
%65 = tail call i32 @DS1302(i32 4, i32 %64)
%66 = tail call i32 @DS1302(i32 1, i32 1)
%67 = tail call i32 @DS1302(i32 1, i32 0)
%68 = lshr i32 %33, 7
%69 = tail call i32 @DS1302(i32 4, i32 %68)
%70 = tail call i32 @DS1302(i32 1, i32 1)
%71 = tail call i32 @DS1302(i32 1, i32 0)
%72 = add nuw nsw i64 %30, 1
%73 = icmp eq i64 %72, 8
br i1 %73, label %74, label %29
74: ; preds = %29
%75 = tail call i32 (...) @Idle_1302()
ret void
}