#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*/ block_ram_init();
long get_millis();
int /*<<< orphan*/ gpio_init();
int /*<<< orphan*/ gpio_write_bit(int, int /*<<< orphan*/);
int /*<<< orphan*/ led_spi_write(int);
int /*<<< orphan*/ led_write_1(int /*<<< orphan*/);
int oled_byte(int);
int /*<<< orphan*/ printf(char *, ...);
int read_register(int);
int /*<<< orphan*/ reset(int);
int /*<<< orphan*/ spi_control(int);
int spi_control_read();
int /*<<< orphan*/ spi_init();
int spi_status();
int /*<<< orphan*/ spi_write(int, int);
int /*<<< orphan*/ spi_write_data(int);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ vbat(int /*<<< orphan*/);
int /*<<< orphan*/ vdd(int /*<<< orphan*/);
int /*<<< orphan*/ write_register(int, int);
int main() {
  gpio_init();
  spi_init();
  block_ram_init();
  write_register(0x4, 0x5);
  printf("Register: %x\n", read_register(0x4));
  gpio_write_bit(8, 0);
  spi_control(0x2);
  usleep(10);
  printf("SPI Control: %x\n", spi_control_read());
  printf("SPI Status: 0x%x\n", spi_status());
  spi_write_data(0x55);
  printf("Power Up Sequence Start\n");
  vdd(0);
  usleep(5000);
  reset(0);
  usleep(5000);
  reset(1);
  usleep(5000);
  vbat(0);
  printf("Power Up Sequence Done\n");
  spi_write(0xAE, 0);
  spi_write(0x8D, 0);
  spi_write(0x14, 0);
  spi_write(0xD9, 0);
  spi_write(0xF1, 0);
  spi_write(0x81, 0);
  spi_write(0xFF, 0);
  spi_write(0xA4, 0);
  spi_write(0xAF, 0);
  usleep(5000);
  spi_write(0x20, 0);
  spi_write(0x01, 0);
  spi_write(0xFF, 1);
  int i;
  for (i = 0; i < 64 * 16; i++) {
    spi_write(oled_byte(0xff), 1);
  }
  long start;
  led_write_1(0);
  usleep(2000);
  for (i = 0; i < 80; i++) {
    led_spi_write(0x00);
    led_spi_write(0x00);
    led_spi_write(0x00);
  }
  start = get_millis();
  for (i = 0; i < 80 / 2; i++) {
    led_spi_write(0xff);
    led_spi_write(0x00);
    led_spi_write(0x00);
  }
  printf("Duration: %d\n", get_millis() - start);
  printf("Delay\n");
  led_write_1(0);
  printf("Clk Low\n");
  printf("Ending\n");
  usleep(2000);
  while (1) {
    for (i = 0; i < 80 / 2; i++) {
      led_spi_write(0x00);
      led_spi_write(0xff);
      led_spi_write(0x00);
    }
    usleep(2000);
    for (i = 0; i < 80 / 2; i++) {
      led_spi_write(0x00);
      led_spi_write(0x00);
      led_spi_write(0xff);
    }
    usleep(2000);
    for (i = 0; i < 80 / 2; i++) {
      led_spi_write(0xff);
      led_spi_write(0xff);
      led_spi_write(0xff);
    }
    usleep(2000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1150 <gpio_init@plt>
mov    $0x0,%al
call   1080 <spi_init@plt>
mov    $0x0,%al
call   1040 <block_ram_init@plt>
mov    $0x4,%edi
mov    $0x5,%esi
call   1110 <write_register@plt>
mov    $0x4,%edi
call   1050 <read_register@plt>
mov    %eax,%esi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   10d0 <gpio_write_bit@plt>
mov    $0x2,%edi
call   1060 <spi_control@plt>
mov    $0xa,%edi
call   1160 <usleep@plt>
mov    $0x0,%al
call   10f0 <spi_control_read@plt>
mov    %eax,%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0x0,%al
call   10e0 <spi_status@plt>
mov    %eax,%esi
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0x55,%edi
call   10c0 <spi_write_data@plt>
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xor    %edi,%edi
call   1120 <vdd@plt>
mov    $0x1388,%edi
call   1160 <usleep@plt>
xor    %edi,%edi
call   1100 <reset@plt>
mov    $0x1388,%edi
call   1160 <usleep@plt>
mov    $0x1,%edi
call   1100 <reset@plt>
mov    $0x1388,%edi
call   1160 <usleep@plt>
xor    %edi,%edi
call   10b0 <vbat@plt>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0xae,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0x8d,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0x14,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xd9,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xf1,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0x81,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xff,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xa4,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xaf,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0x1388,%edi
call   1160 <usleep@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1130 <spi_write@plt>
mov    $0xff,%edi
mov    $0x1,%esi
call   1130 <spi_write@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    1413 <main+0x1d3>
mov    $0xff,%edi
call   1090 <oled_byte@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1130 <spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    13e2 <main+0x1a2>
xor    %edi,%edi
call   1030 <led_write_1@plt>
mov    $0x7d0,%edi
call   1160 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    1458 <main+0x218>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    142b <main+0x1eb>
mov    $0x0,%al
call   1140 <get_millis@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    149a <main+0x25a>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    146a <main+0x22a>
mov    $0x0,%al
call   1140 <get_millis@plt>
mov    %rax,%rsi
sub    -0x10(%rbp),%rsi
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xor    %edi,%edi
call   1030 <led_write_1@plt>
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0xba0(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0x7d0,%edi
call   1160 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    1528 <main+0x2e8>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    14f8 <main+0x2b8>
mov    $0x7d0,%edi
call   1160 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    1569 <main+0x329>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
xor    %edi,%edi
call   1070 <led_spi_write@plt>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1539 <main+0x2f9>
mov    $0x7d0,%edi
call   1160 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    15b0 <main+0x370>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
mov    $0xff,%edi
call   1070 <led_spi_write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    157a <main+0x33a>
mov    $0x7d0,%edi
call   1160 <usleep@plt>
jmp    14f1 <main+0x2b1>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1160 <gpio_init@plt>
xor    %eax,%eax
call   1090 <spi_init@plt>
xor    %eax,%eax
call   1040 <block_ram_init@plt>
mov    $0x4,%edi
mov    $0x5,%esi
call   1120 <write_register@plt>
mov    $0x4,%edi
call   1050 <read_register@plt>
lea    0xd78(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   10e0 <gpio_write_bit@plt>
mov    $0x2,%edi
call   1060 <spi_control@plt>
mov    $0xa,%edi
call   1170 <usleep@plt>
xor    %eax,%eax
call   1100 <spi_control_read@plt>
lea    0xd4f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
xor    %eax,%eax
call   10f0 <spi_status@plt>
lea    0xd49(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    $0x55,%edi
call   10d0 <spi_write_data@plt>
lea    0xd4f(%rip),%rdi
call   1070 <puts@plt>
xor    %edi,%edi
call   1130 <vdd@plt>
mov    $0x1388,%edi
call   1170 <usleep@plt>
xor    %edi,%edi
call   1110 <reset@plt>
mov    $0x1388,%edi
call   1170 <usleep@plt>
mov    $0x1,%edi
call   1110 <reset@plt>
mov    $0x1388,%edi
call   1170 <usleep@plt>
xor    %edi,%edi
call   10c0 <vbat@plt>
lea    0xd1e(%rip),%rdi
call   1070 <puts@plt>
mov    $0xae,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0x8d,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0x14,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xd9,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xf1,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0x81,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xff,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xa4,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xaf,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0x1388,%edi
call   1170 <usleep@plt>
mov    $0x20,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1140 <spi_write@plt>
mov    $0xff,%edi
mov    $0x1,%esi
call   1140 <spi_write@plt>
mov    $0x400,%ebx
mov    $0xff,%edi
call   10a0 <oled_byte@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1140 <spi_write@plt>
add    $0xffffffff,%ebx
jne    13e0 <main+0x190>
xor    %edi,%edi
call   1030 <led_write_1@plt>
mov    $0x7d0,%edi
call   1170 <usleep@plt>
mov    $0x50,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
add    $0xffffffff,%ebx
jne    1420 <main+0x1d0>
xor    %eax,%eax
call   1150 <get_millis@plt>
mov    %rax,%rbx
mov    $0x28,%ebp
nopl   0x0(%rax)
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
add    $0xffffffff,%ebp
jne    1450 <main+0x200>
xor    %eax,%eax
call   1150 <get_millis@plt>
sub    %rbx,%rax
lea    0xbb3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xbdf(%rip),%rdi
call   1070 <puts@plt>
xor    %edi,%edi
call   1030 <led_write_1@plt>
lea    0xbd2(%rip),%rdi
call   1070 <puts@plt>
lea    0xbce(%rip),%rdi
call   1070 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x7d0,%edi
call   1170 <usleep@plt>
mov    $0x28,%ebx
nop
xor    %edi,%edi
call   1080 <led_spi_write@plt>
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
add    $0xffffffff,%ebx
jne    14d0 <main+0x280>
mov    $0x7d0,%edi
call   1170 <usleep@plt>
mov    $0x28,%ebx
nopl   0x0(%rax)
xor    %edi,%edi
call   1080 <led_spi_write@plt>
xor    %edi,%edi
call   1080 <led_spi_write@plt>
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
add    $0xffffffff,%ebx
jne    1500 <main+0x2b0>
mov    $0x7d0,%edi
call   1170 <usleep@plt>
mov    $0x28,%ebx
nopl   0x0(%rax)
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
mov    $0xff,%edi
call   1080 <led_spi_write@plt>
add    $0xffffffff,%ebx
jne    1530 <main+0x2e0>
jmp    14c0 <main+0x270>

LLVM IR (-O0):
@.str = [14 x i8] c"Register: %x\0A\00"
@.str.1 = [17 x i8] c"SPI Control: %x\0A\00"
@.str.2 = [18 x i8] c"SPI Status: 0x%x\0A\00"
@.str.3 = [25 x i8] c"Power Up Sequence Start\0A\00"
@.str.4 = [24 x i8] c"Power Up Sequence Done\0A\00"
@.str.5 = [14 x i8] c"Duration: %d\0A\00"
@.str.6 = [7 x i8] c"Delay\0A\00"
@.str.7 = [9 x i8] c"Clk Low\0A\00"
@.str.8 = [8 x i8] c"Ending\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (...) @gpio_init()
%5 = call i32 (...) @spi_init()
%6 = call i32 (...) @block_ram_init()
%7 = call i32 @write_register(i32 4, i32 5)
%8 = call i32 @read_register(i32 4)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @gpio_write_bit(i32 8, i32 0)
%11 = call i32 @spi_control(i32 2)
%12 = call i32 @usleep(i32 10)
%13 = call i32 (...) @spi_control_read()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @spi_status()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 @spi_write_data(i32 85)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @vdd(i32 0)
%20 = call i32 @usleep(i32 5000)
%21 = call i32 @reset(i32 0)
%22 = call i32 @usleep(i32 5000)
%23 = call i32 @reset(i32 1)
%24 = call i32 @usleep(i32 5000)
%25 = call i32 @vbat(i32 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @spi_write(i32 174, i32 0)
%28 = call i32 @spi_write(i32 141, i32 0)
%29 = call i32 @spi_write(i32 20, i32 0)
%30 = call i32 @spi_write(i32 217, i32 0)
%31 = call i32 @spi_write(i32 241, i32 0)
%32 = call i32 @spi_write(i32 129, i32 0)
%33 = call i32 @spi_write(i32 255, i32 0)
%34 = call i32 @spi_write(i32 164, i32 0)
%35 = call i32 @spi_write(i32 175, i32 0)
%36 = call i32 @usleep(i32 5000)
%37 = call i32 @spi_write(i32 32, i32 0)
%38 = call i32 @spi_write(i32 1, i32 0)
%39 = call i32 @spi_write(i32 255, i32 1)
store i32 0, i32* %2
br label %40
40: ; preds = %46, %0
%41 = load i32, i32* %2
%42 = icmp slt i32 %41, 1024
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = call i32 @oled_byte(i32 255)
%45 = call i32 @spi_write(i32 %44, i32 1)
br label %46
46: ; preds = %43
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %40
49: ; preds = %40
%50 = call i32 @led_write_1(i32 0)
%51 = call i32 @usleep(i32 2000)
store i32 0, i32* %2
br label %52
52: ; preds = %59, %49
%53 = load i32, i32* %2
%54 = icmp slt i32 %53, 80
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = call i32 @led_spi_write(i32 0)
%57 = call i32 @led_spi_write(i32 0)
%58 = call i32 @led_spi_write(i32 0)
br label %59
59: ; preds = %55
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %52
62: ; preds = %52
%63 = call i64 (...) @get_millis()
store i64 %63, i64* %3
store i32 0, i32* %2
br label %64
64: ; preds = %71, %62
%65 = load i32, i32* %2
%66 = icmp slt i32 %65, 40
br i1 %66, label %67, label %74
67: ; preds = %64
%68 = call i32 @led_spi_write(i32 255)
%69 = call i32 @led_spi_write(i32 0)
%70 = call i32 @led_spi_write(i32 0)
br label %71
71: ; preds = %67
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %64
74: ; preds = %64
%75 = call i64 (...) @get_millis()
%76 = load i64, i64* %3
%77 = sub nsw i64 %75, %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%80 = call i32 @led_write_1(i32 0)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%83 = call i32 @usleep(i32 2000)
br label %84
84: ; preds = %74, %119
store i32 0, i32* %2
br label %85
85: ; preds = %92, %84
%86 = load i32, i32* %2
%87 = icmp slt i32 %86, 40
br i1 %87, label %88, label %95
88: ; preds = %85
%89 = call i32 @led_spi_write(i32 0)
%90 = call i32 @led_spi_write(i32 255)
%91 = call i32 @led_spi_write(i32 0)
br label %92
92: ; preds = %88
%93 = load i32, i32* %2
%94 = add nsw i32 %93, 1
store i32 %94, i32* %2
br label %85
95: ; preds = %85
%96 = call i32 @usleep(i32 2000)
store i32 0, i32* %2
br label %97
97: ; preds = %104, %95
%98 = load i32, i32* %2
%99 = icmp slt i32 %98, 40
br i1 %99, label %100, label %107
100: ; preds = %97
%101 = call i32 @led_spi_write(i32 0)
%102 = call i32 @led_spi_write(i32 0)
%103 = call i32 @led_spi_write(i32 255)
br label %104
104: ; preds = %100
%105 = load i32, i32* %2
%106 = add nsw i32 %105, 1
store i32 %106, i32* %2
br label %97
107: ; preds = %97
%108 = call i32 @usleep(i32 2000)
store i32 0, i32* %2
br label %109
109: ; preds = %116, %107
%110 = load i32, i32* %2
%111 = icmp slt i32 %110, 40
br i1 %111, label %112, label %119
112: ; preds = %109
%113 = call i32 @led_spi_write(i32 255)
%114 = call i32 @led_spi_write(i32 255)
%115 = call i32 @led_spi_write(i32 255)
br label %116
116: ; preds = %112
%117 = load i32, i32* %2
%118 = add nsw i32 %117, 1
store i32 %118, i32* %2
br label %109
119: ; preds = %109
%120 = call i32 @usleep(i32 2000)
br label %84
}

LLVM IR (-O2):
@.str = [14 x i8] c"Register: %x\0A\00"
@.str.1 = [17 x i8] c"SPI Control: %x\0A\00"
@.str.2 = [18 x i8] c"SPI Status: 0x%x\0A\00"
@.str.5 = [14 x i8] c"Duration: %d\0A\00"
@str = [24 x i8] c"Power Up Sequence Start\00"
@str.9 = [23 x i8] c"Power Up Sequence Done\00"
@str.10 = [6 x i8] c"Delay\00"
@str.11 = [8 x i8] c"Clk Low\00"
@str.12 = [7 x i8] c"Ending\00"
define i32 @main() {
%1 = tail call i32 (...) @gpio_init()
%2 = tail call i32 (...) @spi_init()
%3 = tail call i32 (...) @block_ram_init()
%4 = tail call i32 @write_register(i32 4, i32 5)
%5 = tail call i32 @read_register(i32 4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @gpio_write_bit(i32 8, i32 0)
%8 = tail call i32 @spi_control(i32 2)
%9 = tail call i32 @usleep(i32 10)
%10 = tail call i32 (...) @spi_control_read()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i32 (...) @spi_status()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = tail call i32 @spi_write_data(i32 85)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @vdd(i32 0)
%17 = tail call i32 @usleep(i32 5000)
%18 = tail call i32 @reset(i32 0)
%19 = tail call i32 @usleep(i32 5000)
%20 = tail call i32 @reset(i32 1)
%21 = tail call i32 @usleep(i32 5000)
%22 = tail call i32 @vbat(i32 0)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%24 = tail call i32 @spi_write(i32 174, i32 0)
%25 = tail call i32 @spi_write(i32 141, i32 0)
%26 = tail call i32 @spi_write(i32 20, i32 0)
%27 = tail call i32 @spi_write(i32 217, i32 0)
%28 = tail call i32 @spi_write(i32 241, i32 0)
%29 = tail call i32 @spi_write(i32 129, i32 0)
%30 = tail call i32 @spi_write(i32 255, i32 0)
%31 = tail call i32 @spi_write(i32 164, i32 0)
%32 = tail call i32 @spi_write(i32 175, i32 0)
%33 = tail call i32 @usleep(i32 5000)
%34 = tail call i32 @spi_write(i32 32, i32 0)
%35 = tail call i32 @spi_write(i32 1, i32 0)
%36 = tail call i32 @spi_write(i32 255, i32 1)
br label %37
37: ; preds = %0, %37
%38 = phi i32 [ 0, %0 ], [ %41, %37 ]
%39 = tail call i32 @oled_byte(i32 255)
%40 = tail call i32 @spi_write(i32 %39, i32 1)
%41 = add nuw nsw i32 %38, 1
%42 = icmp eq i32 %41, 1024
br i1 %42, label %43, label %37
43: ; preds = %37
%44 = tail call i32 @led_write_1(i32 0)
%45 = tail call i32 @usleep(i32 2000)
br label %46
46: ; preds = %43, %46
%47 = phi i32 [ 0, %43 ], [ %51, %46 ]
%48 = tail call i32 @led_spi_write(i32 0)
%49 = tail call i32 @led_spi_write(i32 0)
%50 = tail call i32 @led_spi_write(i32 0)
%51 = add nuw nsw i32 %47, 1
%52 = icmp eq i32 %51, 80
br i1 %52, label %53, label %46
53: ; preds = %46
%54 = tail call i64 (...) @get_millis()
br label %55
55: ; preds = %53, %55
%56 = phi i32 [ 0, %53 ], [ %60, %55 ]
%57 = tail call i32 @led_spi_write(i32 255)
%58 = tail call i32 @led_spi_write(i32 0)
%59 = tail call i32 @led_spi_write(i32 0)
%60 = add nuw nsw i32 %56, 1
%61 = icmp eq i32 %60, 40
br i1 %61, label %62, label %55
62: ; preds = %55
%63 = tail call i64 (...) @get_millis()
%64 = sub nsw i64 %63, %54
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 %64)
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0))
%67 = tail call i32 @led_write_1(i32 0)
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.12, i64 0, i64 0))
br label %70
70: ; preds = %90, %62
%71 = tail call i32 @usleep(i32 2000)
br label %72
72: ; preds = %70, %72
%73 = phi i32 [ 0, %70 ], [ %77, %72 ]
%74 = tail call i32 @led_spi_write(i32 0)
%75 = tail call i32 @led_spi_write(i32 255)
%76 = tail call i32 @led_spi_write(i32 0)
%77 = add nuw nsw i32 %73, 1
%78 = icmp eq i32 %77, 40
br i1 %78, label %79, label %72
79: ; preds = %72
%80 = tail call i32 @usleep(i32 2000)
br label %81
81: ; preds = %79, %81
%82 = phi i32 [ 0, %79 ], [ %86, %81 ]
%83 = tail call i32 @led_spi_write(i32 0)
%84 = tail call i32 @led_spi_write(i32 0)
%85 = tail call i32 @led_spi_write(i32 255)
%86 = add nuw nsw i32 %82, 1
%87 = icmp eq i32 %86, 40
br i1 %87, label %88, label %81
88: ; preds = %81
%89 = tail call i32 @usleep(i32 2000)
br label %90
90: ; preds = %88, %90
%91 = phi i32 [ 0, %88 ], [ %95, %90 ]
%92 = tail call i32 @led_spi_write(i32 255)
%93 = tail call i32 @led_spi_write(i32 255)
%94 = tail call i32 @led_spi_write(i32 255)
%95 = add nuw nsw i32 %91, 1
%96 = icmp eq i32 %95, 40
br i1 %96, label %70, label %90
}