#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*/ _cc3_set_cam_ddr(int);
int /*<<< orphan*/ _cc3_set_cam_ddr_sccb_idle();
int /*<<< orphan*/ _cc3_set_cam_ddr_sccb_write();
bool _cc3_sccb_send(unsigned int num, unsigned int *buffer) {
  bool ack;
  unsigned int i, k;
  unsigned int data;
  (*(volatile unsigned long *)((0xE002800C))) = 0x00800000;
  _cc3_set_cam_ddr(0x00BEBDC9);
  (*(volatile unsigned long *)((0xE002800C))) = 0x00400000;
  _cc3_set_cam_ddr_sccb_write();
  for (k = 0; k != num; k++) {
    data = buffer[k];
    for (i = 0; !(i & 8); i++) {
      if (data & 0x80) {
        _cc3_set_cam_ddr(0x007EBDC9);
        _cc3_set_cam_ddr_sccb_idle();
      } else {
        _cc3_set_cam_ddr_sccb_write();
        _cc3_set_cam_ddr(0x00BEBDC9);
      }
      while (!((*(volatile unsigned long *)((0xE0028000))) & 0x00400000))
        ;
      if (data & 0x08) {
        _cc3_set_cam_ddr(0x007EBDC9);
      } else {
        _cc3_set_cam_ddr_sccb_write();
      }
      data <<= 1;
    }
    _cc3_set_cam_ddr(0x007EBDC9);
    _cc3_set_cam_ddr_sccb_idle();
    ack = false;
    if ((*(volatile unsigned long *)((0xE0028000))) & 0x00800000) {
      ack = true;
      break;
    }
    _cc3_set_cam_ddr_sccb_write();
  }
  _cc3_set_cam_ddr(0x00BEBDC9);
  _cc3_set_cam_ddr_sccb_idle();
  return ack;
}


x86 assembly (clang, -O0):
<_cc3_sccb_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xe002800c,%eax
movq   $0x800000,(%rax)
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
mov    $0xe002800c,%eax
movq   $0x400000,(%rax)
mov    $0x0,%al
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     129d <_cc3_sccb_send+0x16d>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11aa <_cc3_sccb_send+0x7a>
jmp    124c <_cc3_sccb_send+0x11c>
mov    -0x20(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11d1 <_cc3_sccb_send+0xa1>
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
mov    $0x0,%al
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
jmp    11e2 <_cc3_sccb_send+0xb2>
mov    $0x0,%al
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
jmp    11e7 <_cc3_sccb_send+0xb7>
mov    $0xe0028000,%eax
mov    (%rax),%rax
and    $0x400000,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120b <_cc3_sccb_send+0xdb>
jmp    1210 <_cc3_sccb_send+0xe0>
jmp    11e7 <_cc3_sccb_send+0xb7>
mov    -0x20(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     122e <_cc3_sccb_send+0xfe>
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
jmp    1235 <_cc3_sccb_send+0x105>
mov    $0x0,%al
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <_cc3_sccb_send+0x5f>
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
mov    $0x0,%al
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
movl   $0x0,-0x14(%rbp)
mov    $0xe0028000,%eax
mov    (%rax),%rax
and    $0x800000,%rax
cmp    $0x0,%rax
je     1288 <_cc3_sccb_send+0x158>
movl   $0x1,-0x14(%rbp)
jmp    129d <_cc3_sccb_send+0x16d>
mov    $0x0,%al
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <_cc3_sccb_send+0x3f>
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
mov    $0x0,%al
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cc3_sccb_send>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    $0xe0028000,%ebx
movq   $0x800000,0xc(%rbx)
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
movq   $0x400000,0xc(%rbx)
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
test   %r14d,%r14d
je     1239 <_cc3_sccb_send+0x109>
mov    %r14d,%r14d
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%r15,%r13,4),%ebp
xor    %r12d,%r12d
jmp    11a3 <_cc3_sccb_send+0x73>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
add    %ebp,%ebp
add    $0x1,%r12d
cmp    $0x8,%r12d
je     1200 <_cc3_sccb_send+0xd0>
test   $0x80,%bpl
jne    11c0 <_cc3_sccb_send+0x90>
xor    %eax,%eax
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
jmp    11e0 <_cc3_sccb_send+0xb0>
nopl   0x0(%rax)
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
xor    %eax,%eax
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
testq  $0x400000,(%rbx)
je     11e0 <_cc3_sccb_send+0xb0>
test   $0x8,%bpl
je     1190 <_cc3_sccb_send+0x60>
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
jmp    1197 <_cc3_sccb_send+0x67>
nopl   0x0(%rax,%rax,1)
mov    $0x7ebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
xor    %eax,%eax
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
testq  $0x800000,(%rbx)
jne    1233 <_cc3_sccb_send+0x103>
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <_cc3_set_cam_ddr_sccb_write@plt>
add    $0x1,%r13
cmp    %r14,%r13
jne    1180 <_cc3_sccb_send+0x50>
jmp    1239 <_cc3_sccb_send+0x109>
mov    $0x1,%r12d
mov    $0xbebdc9,%edi
call   1030 <_cc3_set_cam_ddr@plt>
xor    %eax,%eax
call   1040 <_cc3_set_cam_ddr_sccb_idle@plt>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_cc3_sccb_send(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* %3
store i32* %1, i32** %4
store volatile i64 8388608, i64* inttoptr (i64 3758260236 to i64*)
%9 = call i32 @_cc3_set_cam_ddr(i32 12500425)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%10 = call i32 (...) @_cc3_set_cam_ddr_sccb_write()
store i32 0, i32* %7
br label %11
11: ; preds = %66, %2
%12 = load i32, i32* %7
%13 = load i32, i32* %3
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %69
15: ; preds = %11
%16 = load i32*, i32** %4
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %8
store i32 0, i32* %6
br label %21
21: ; preds = %54, %15
%22 = load i32, i32* %6
%23 = and i32 %22, 8
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %57
26: ; preds = %21
%27 = load i32, i32* %8
%28 = and i32 %27, 128
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = call i32 @_cc3_set_cam_ddr(i32 8306121)
%32 = call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
br label %36
33: ; preds = %26
%34 = call i32 (...) @_cc3_set_cam_ddr_sccb_write()
%35 = call i32 @_cc3_set_cam_ddr(i32 12500425)
br label %36
36: ; preds = %33, %30
br label %37
37: ; preds = %42, %36
%38 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%39 = and i64 %38, 4194304
%40 = icmp ne i64 %39, 0
%41 = xor i1 %40, true
br i1 %41, label %42, label %43
42: ; preds = %37
br label %37
43: ; preds = %37
%44 = load i32, i32* %8
%45 = and i32 %44, 8
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @_cc3_set_cam_ddr(i32 8306121)
br label %51
49: ; preds = %43
%50 = call i32 (...) @_cc3_set_cam_ddr_sccb_write()
br label %51
51: ; preds = %49, %47
%52 = load i32, i32* %8
%53 = shl i32 %52, 1
store i32 %53, i32* %8
br label %54
54: ; preds = %51
%55 = load i32, i32* %6
%56 = add i32 %55, 1
store i32 %56, i32* %6
br label %21
57: ; preds = %21
%58 = call i32 @_cc3_set_cam_ddr(i32 8306121)
%59 = call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
store i32 0, i32* %5
%60 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%61 = and i64 %60, 8388608
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %57
store i32 1, i32* %5
br label %69
64: ; preds = %57
%65 = call i32 (...) @_cc3_set_cam_ddr_sccb_write()
br label %66
66: ; preds = %64
%67 = load i32, i32* %7
%68 = add i32 %67, 1
store i32 %68, i32* %7
br label %11
69: ; preds = %63, %11
%70 = call i32 @_cc3_set_cam_ddr(i32 12500425)
%71 = call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
%72 = load i32, i32* %5
ret i32 %72
}

LLVM IR (-O2):
define i32 @_cc3_sccb_send(i32 %0, i32* nocapture %1) {
store volatile i64 8388608, i64* inttoptr (i64 3758260236 to i64*)
%3 = tail call i32 @_cc3_set_cam_ddr(i32 12500425)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
%4 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_write()
%5 = icmp eq i32 %0, 0
br i1 %5, label %49, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %45
%9 = phi i64 [ 0, %6 ], [ %47, %45 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
br label %12
12: ; preds = %8, %35
%13 = phi i32 [ %11, %8 ], [ %36, %35 ]
%14 = phi i32 [ 0, %8 ], [ %37, %35 ]
%15 = and i32 %13, 128
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = tail call i32 @_cc3_set_cam_ddr(i32 8306121)
%19 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
br label %23
20: ; preds = %12
%21 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_write()
%22 = tail call i32 @_cc3_set_cam_ddr(i32 12500425)
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23, %24
%25 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%26 = and i64 %25, 4194304
%27 = icmp eq i64 %26, 0
br i1 %27, label %24, label %28
28: ; preds = %24
%29 = and i32 %13, 8
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = tail call i32 @_cc3_set_cam_ddr(i32 8306121)
br label %35
33: ; preds = %28
%34 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_write()
br label %35
35: ; preds = %33, %31
%36 = shl i32 %13, 1
%37 = add nuw nsw i32 %14, 1
%38 = icmp eq i32 %37, 8
br i1 %38, label %39, label %12
39: ; preds = %35
%40 = tail call i32 @_cc3_set_cam_ddr(i32 8306121)
%41 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
%42 = load volatile i64, i64* inttoptr (i64 3758260224 to i64*)
%43 = and i64 %42, 8388608
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_write()
%47 = add nuw nsw i64 %9, 1
%48 = icmp eq i64 %47, %7
br i1 %48, label %49, label %8
49: ; preds = %45, %39, %2
%50 = phi i32 [ 0, %2 ], [ 1, %39 ], [ 0, %45 ]
%51 = tail call i32 @_cc3_set_cam_ddr(i32 12500425)
%52 = tail call i32 (...) @_cc3_set_cam_ddr_sccb_idle()
ret i32 %50
}