#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*/ Dorado9211ClearCS();
int /*<<< orphan*/ Dorado9211ClearDataOut();
int /*<<< orphan*/ Dorado9211SetCS();
int /*<<< orphan*/ Dorado9211SetDataOut();
int /*<<< orphan*/ Dorado9211ToggleClock();
void Dorado9211WriteReg(unsigned short index, unsigned long data) {
  unsigned char i;
  Dorado9211ClearDataOut();
  Dorado9211SetDataOut();
  Dorado9211SetCS();
  Dorado9211ToggleClock();
  Dorado9211SetDataOut();
  Dorado9211ToggleClock();
  for (i = 0; i < 12; i++) {
    if (index & 0x1) {
      Dorado9211SetDataOut();
    } else {
      Dorado9211ClearDataOut();
    }
    Dorado9211ToggleClock();
    index >>= 1;
  }
  Dorado9211SetDataOut();
  Dorado9211ToggleClock();
  for (i = 0; i < 32; i++) {
    if (data & 0x1) {
      Dorado9211SetDataOut();
    } else {
      Dorado9211ClearDataOut();
    }
    Dorado9211ToggleClock();
    data >>= 1;
  }
  Dorado9211ClearCS();
  Dorado9211ToggleClock();
  Dorado9211ToggleClock();
  Dorado9211ToggleClock();
  Dorado9211ToggleClock();
}


x86 assembly (clang, -O0):
<Dorado9211WriteReg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <Dorado9211ClearDataOut@plt>
mov    $0x0,%al
call   1070 <Dorado9211SetDataOut@plt>
mov    $0x0,%al
call   1050 <Dorado9211SetCS@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
mov    $0x0,%al
call   1070 <Dorado9211SetDataOut@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0xc,%eax
jge    11e0 <Dorado9211WriteReg+0x90>
movzwl -0x2(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ba <Dorado9211WriteReg+0x6a>
mov    $0x0,%al
call   1070 <Dorado9211SetDataOut@plt>
jmp    11c1 <Dorado9211WriteReg+0x71>
mov    $0x0,%al
call   1060 <Dorado9211ClearDataOut@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
movzwl -0x2(%rbp),%eax
sar    $0x1,%eax
mov    %ax,-0x2(%rbp)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1191 <Dorado9211WriteReg+0x41>
mov    $0x0,%al
call   1070 <Dorado9211SetDataOut@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jge    1244 <Dorado9211WriteReg+0xf4>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     121d <Dorado9211WriteReg+0xcd>
mov    $0x0,%al
call   1070 <Dorado9211SetDataOut@plt>
jmp    1224 <Dorado9211WriteReg+0xd4>
mov    $0x0,%al
call   1060 <Dorado9211ClearDataOut@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
mov    -0x10(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11f2 <Dorado9211WriteReg+0xa2>
mov    $0x0,%al
call   1040 <Dorado9211ClearCS@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
mov    $0x0,%al
call   1030 <Dorado9211ToggleClock@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dorado9211WriteReg>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
xor    %eax,%eax
call   1060 <Dorado9211ClearDataOut@plt>
xor    %eax,%eax
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1050 <Dorado9211SetCS@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x1,%bl
jne    1190 <Dorado9211WriteReg+0x40>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    1195 <Dorado9211WriteReg+0x45>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x2,%bl
jne    11aa <Dorado9211WriteReg+0x5a>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    11af <Dorado9211WriteReg+0x5f>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x4,%bl
jne    11c4 <Dorado9211WriteReg+0x74>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    11c9 <Dorado9211WriteReg+0x79>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    11de <Dorado9211WriteReg+0x8e>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    11e3 <Dorado9211WriteReg+0x93>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x10,%bl
jne    11f8 <Dorado9211WriteReg+0xa8>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    11fd <Dorado9211WriteReg+0xad>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x20,%bl
jne    1212 <Dorado9211WriteReg+0xc2>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    1217 <Dorado9211WriteReg+0xc7>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x40,%bl
jne    122c <Dorado9211WriteReg+0xdc>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    1231 <Dorado9211WriteReg+0xe1>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x80,%bl
jne    1246 <Dorado9211WriteReg+0xf6>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    124b <Dorado9211WriteReg+0xfb>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x100,%ebx
jne    1263 <Dorado9211WriteReg+0x113>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    1268 <Dorado9211WriteReg+0x118>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x200,%ebx
jne    1280 <Dorado9211WriteReg+0x130>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    1285 <Dorado9211WriteReg+0x135>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x400,%ebx
jne    129d <Dorado9211WriteReg+0x14d>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    12a2 <Dorado9211WriteReg+0x152>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
test   $0x800,%ebx
jne    12ba <Dorado9211WriteReg+0x16a>
call   1060 <Dorado9211ClearDataOut@plt>
jmp    12bf <Dorado9211WriteReg+0x16f>
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
call   1070 <Dorado9211SetDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
mov    $0x20,%bl
jmp    12f4 <Dorado9211WriteReg+0x1a4>
nopl   0x0(%rax,%rax,1)
call   1060 <Dorado9211ClearDataOut@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
shr    %rbp
add    $0xff,%bl
je     1303 <Dorado9211WriteReg+0x1b3>
xor    %eax,%eax
test   $0x1,%bpl
je     12e0 <Dorado9211WriteReg+0x190>
call   1070 <Dorado9211SetDataOut@plt>
jmp    12e5 <Dorado9211WriteReg+0x195>
xor    %eax,%eax
call   1040 <Dorado9211ClearCS@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
call   1030 <Dorado9211ToggleClock@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <Dorado9211ToggleClock@plt>

LLVM IR (-O0):
define void @Dorado9211WriteReg(i16 zeroext %0, i64 %1) {
%3 = alloca i16
%4 = alloca i64
%5 = alloca i8
store i16 %0, i16* %3
store i64 %1, i64* %4
%6 = call i32 (...) @Dorado9211ClearDataOut()
%7 = call i32 (...) @Dorado9211SetDataOut()
%8 = call i32 (...) @Dorado9211SetCS()
%9 = call i32 (...) @Dorado9211ToggleClock()
%10 = call i32 (...) @Dorado9211SetDataOut()
%11 = call i32 (...) @Dorado9211ToggleClock()
store i8 0, i8* %5
br label %12
12: ; preds = %31, %2
%13 = load i8, i8* %5
%14 = zext i8 %13 to i32
%15 = icmp slt i32 %14, 12
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load i16, i16* %3
%18 = zext i16 %17 to i32
%19 = and i32 %18, 1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 (...) @Dorado9211SetDataOut()
br label %25
23: ; preds = %16
%24 = call i32 (...) @Dorado9211ClearDataOut()
br label %25
25: ; preds = %23, %21
%26 = call i32 (...) @Dorado9211ToggleClock()
%27 = load i16, i16* %3
%28 = zext i16 %27 to i32
%29 = ashr i32 %28, 1
%30 = trunc i32 %29 to i16
store i16 %30, i16* %3
br label %31
31: ; preds = %25
%32 = load i8, i8* %5
%33 = add i8 %32, 1
store i8 %33, i8* %5
br label %12
34: ; preds = %12
%35 = call i32 (...) @Dorado9211SetDataOut()
%36 = call i32 (...) @Dorado9211ToggleClock()
store i8 0, i8* %5
br label %37
37: ; preds = %53, %34
%38 = load i8, i8* %5
%39 = zext i8 %38 to i32
%40 = icmp slt i32 %39, 32
br i1 %40, label %41, label %56
41: ; preds = %37
%42 = load i64, i64* %4
%43 = and i64 %42, 1
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (...) @Dorado9211SetDataOut()
br label %49
47: ; preds = %41
%48 = call i32 (...) @Dorado9211ClearDataOut()
br label %49
49: ; preds = %47, %45
%50 = call i32 (...) @Dorado9211ToggleClock()
%51 = load i64, i64* %4
%52 = lshr i64 %51, 1
store i64 %52, i64* %4
br label %53
53: ; preds = %49
%54 = load i8, i8* %5
%55 = add i8 %54, 1
store i8 %55, i8* %5
br label %37
56: ; preds = %37
%57 = call i32 (...) @Dorado9211ClearCS()
%58 = call i32 (...) @Dorado9211ToggleClock()
%59 = call i32 (...) @Dorado9211ToggleClock()
%60 = call i32 (...) @Dorado9211ToggleClock()
%61 = call i32 (...) @Dorado9211ToggleClock()
ret void
}

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