#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ OSD9616_multiSend(int *, int);
int /*<<< orphan*/ OSD9616_send(int, int);
int amplitude2bargraph(int);
int oled_display_bargraph(int *message) {
  uint16_t cmd[10];
  int i;
  uint16_t input;
  uint16_t pixels;
  OSD9616_send(0x00, 0x2E);
  OSD9616_send(0x00, 0x00);
  OSD9616_send(0x00, 0x10);
  OSD9616_send(0x00, 0xb0 + 0);
  for (i = 95 / 2; i >= 0; i--) {
    input = amplitude2bargraph(message[i]);
    pixels = (input & 0xFF);
    OSD9616_send(0x40, pixels);
    OSD9616_send(0x40, pixels);
  }
  OSD9616_send(0x00, 0x00);
  OSD9616_send(0x00, 0x10);
  OSD9616_send(0x00, 0xb0 + 1);
  for (i = 95 / 2; i >= 0; i--) {
    input = amplitude2bargraph(message[i]);
    pixels = (input >> 8);
    OSD9616_send(0x40, pixels);
    OSD9616_send(0x40, pixels);
  }
  cmd[0] = 0x00;
  cmd[1] = 0x29;
  cmd[2] = 0x00;
  cmd[3] = 0x00;
  cmd[4] = 0x03;
  cmd[5] = 0x01;
  cmd[6] = 0x01;
  OSD9616_multiSend(cmd, 7);
  OSD9616_send(0x00, 0x2E);
  cmd[0] = 0x00;
  cmd[1] = 0xa3;
  cmd[2] = 0x08;
  cmd[3] = 0x08;
  OSD9616_multiSend(cmd, 4);
  return 0;
}


x86 assembly (clang, -O0):
<oled_display_bargraph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
mov    $0x2e,%esi
call   1050 <OSD9616_send@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb0,%esi
call   1050 <OSD9616_send@plt>
movl   $0x2f,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11c0 <oled_display_bargraph+0x90>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <amplitude2bargraph@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    $0x40,%edi
call   1050 <OSD9616_send@plt>
mov    -0x3c(%rbp),%esi
mov    $0x40,%edi
call   1050 <OSD9616_send@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1170 <oled_display_bargraph+0x40>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb1,%esi
call   1050 <OSD9616_send@plt>
movl   $0x2f,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     1236 <oled_display_bargraph+0x106>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <amplitude2bargraph@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
mov    $0x40,%edi
call   1050 <OSD9616_send@plt>
mov    -0x3c(%rbp),%esi
mov    $0x40,%edi
call   1050 <OSD9616_send@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11e8 <oled_display_bargraph+0xb8>
movl   $0x0,-0x30(%rbp)
movl   $0x29,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x3,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x7,%esi
call   1030 <OSD9616_multiSend@plt>
xor    %edi,%edi
mov    $0x2e,%esi
call   1050 <OSD9616_send@plt>
movl   $0x0,-0x30(%rbp)
movl   $0xa3,-0x2c(%rbp)
movl   $0x8,-0x28(%rbp)
movl   $0x8,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1030 <OSD9616_multiSend@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oled_display_bargraph>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
xor    %edi,%edi
mov    $0x2e,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb0,%esi
call   1050 <OSD9616_send@plt>
mov    $0x2f,%ebx
nopl   (%rax)
mov    (%r14,%rbx,4),%edi
call   1040 <amplitude2bargraph@plt>
movzbl %al,%ebp
mov    $0x40,%edi
mov    %ebp,%esi
call   1050 <OSD9616_send@plt>
mov    $0x40,%edi
mov    %ebp,%esi
call   1050 <OSD9616_send@plt>
add    $0xffffffffffffffff,%rbx
jb     1170 <oled_display_bargraph+0x40>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1050 <OSD9616_send@plt>
xor    %edi,%edi
mov    $0xb1,%esi
call   1050 <OSD9616_send@plt>
mov    $0x2f,%ebx
mov    (%r14,%rbx,4),%edi
call   1040 <amplitude2bargraph@plt>
mov    %eax,%ebp
sar    $0x8,%ebp
mov    $0x40,%edi
mov    %ebp,%esi
call   1050 <OSD9616_send@plt>
mov    $0x40,%edi
mov    %ebp,%esi
call   1050 <OSD9616_send@plt>
add    $0xffffffffffffffff,%rbx
jb     11c0 <oled_display_bargraph+0x90>
movaps 0xe0d(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x100000003,%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x18(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <OSD9616_multiSend@plt>
xor    %edi,%edi
mov    $0x2e,%esi
call   1050 <OSD9616_send@plt>
movaps 0xddf(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <OSD9616_multiSend@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @oled_display_bargraph(i32* %0) {
%2 = alloca i32*
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = call i32 @OSD9616_send(i32 0, i32 46)
%8 = call i32 @OSD9616_send(i32 0, i32 0)
%9 = call i32 @OSD9616_send(i32 0, i32 16)
%10 = call i32 @OSD9616_send(i32 0, i32 176)
store i32 47, i32* %4
br label %11
11: ; preds = %27, %1
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32*, i32** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @amplitude2bargraph(i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = and i32 %21, 255
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 @OSD9616_send(i32 64, i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @OSD9616_send(i32 64, i32 %25)
br label %27
27: ; preds = %14
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %11
30: ; preds = %11
%31 = call i32 @OSD9616_send(i32 0, i32 0)
%32 = call i32 @OSD9616_send(i32 0, i32 16)
%33 = call i32 @OSD9616_send(i32 0, i32 177)
store i32 47, i32* %4
br label %34
34: ; preds = %50, %30
%35 = load i32, i32* %4
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %53
37: ; preds = %34
%38 = load i32*, i32** %2
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = call i32 @amplitude2bargraph(i32 %42)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = ashr i32 %44, 8
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = call i32 @OSD9616_send(i32 64, i32 %46)
%48 = load i32, i32* %6
%49 = call i32 @OSD9616_send(i32 64, i32 %48)
br label %50
50: ; preds = %37
%51 = load i32, i32* %4
%52 = add nsw i32 %51, -1
store i32 %52, i32* %4
br label %34
53: ; preds = %34
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %54
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 41, i32* %55
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 0, i32* %56
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 0, i32* %57
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
store i32 3, i32* %58
%59 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
store i32 1, i32* %59
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
store i32 1, i32* %60
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%62 = call i32 @OSD9616_multiSend(i32* %61, i32 7)
%63 = call i32 @OSD9616_send(i32 0, i32 46)
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %64
%65 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 163, i32* %65
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 8, i32* %66
%67 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 8, i32* %67
%68 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%69 = call i32 @OSD9616_multiSend(i32* %68, i32 4)
ret i32 0
}

LLVM IR (-O2):
define i32 @oled_display_bargraph(i32* nocapture %0) {
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = tail call i32 @OSD9616_send(i32 0, i32 46)
%5 = tail call i32 @OSD9616_send(i32 0, i32 0)
%6 = tail call i32 @OSD9616_send(i32 0, i32 16)
%7 = tail call i32 @OSD9616_send(i32 0, i32 176)
br label %8
8: ; preds = %1, %8
%9 = phi i64 [ 47, %1 ], [ %16, %8 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @amplitude2bargraph(i32 %11)
%13 = and i32 %12, 255
%14 = tail call i32 @OSD9616_send(i32 64, i32 %13)
%15 = tail call i32 @OSD9616_send(i32 64, i32 %13)
%16 = add nsw i64 %9, -1
%17 = icmp eq i64 %9, 0
br i1 %17, label %18, label %8
18: ; preds = %8
%19 = tail call i32 @OSD9616_send(i32 0, i32 0)
%20 = tail call i32 @OSD9616_send(i32 0, i32 16)
%21 = tail call i32 @OSD9616_send(i32 0, i32 177)
br label %22
22: ; preds = %18, %22
%23 = phi i64 [ 47, %18 ], [ %30, %22 ]
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = tail call i32 @amplitude2bargraph(i32 %25)
%27 = ashr i32 %26, 8
%28 = tail call i32 @OSD9616_send(i32 64, i32 %27)
%29 = tail call i32 @OSD9616_send(i32 64, i32 %27)
%30 = add nsw i64 %23, -1
%31 = icmp eq i64 %23, 0
br i1 %31, label %32, label %22
32: ; preds = %22
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%34 = bitcast [10 x i32]* %2 to <4 x i32>*
store <4 x i32> <i32 0, i32 41, i32 0, i32 0>, <4 x i32>* %34
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
store i32 3, i32* %35
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
store i32 1, i32* %36
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
store i32 1, i32* %37
%38 = call i32 @OSD9616_multiSend(i32* %33, i32 7)
%39 = call i32 @OSD9616_send(i32 0, i32 46)
%40 = bitcast [10 x i32]* %2 to <4 x i32>*
store <4 x i32> <i32 0, i32 163, i32 8, i32 8>, <4 x i32>* %40
%41 = call i32 @OSD9616_multiSend(i32* %33, i32 4)
ret i32 0
}