#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 amplitude2signal(int);
int oled_display_waveform(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; i >= 0; i--) {
    input = amplitude2signal(message[i]);
    pixels = (input & 0xFF);
    OSD9616_send(0x40, pixels);
  }
  OSD9616_send(0x00, 0x00);
  OSD9616_send(0x00, 0x10);
  OSD9616_send(0x00, 0xb0 + 1);
  for (i = 95; i >= 0; i--) {
    input = amplitude2signal(message[i]);
    pixels = (input >> 8);
    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_waveform>:
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   $0x5f,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11b3 <oled_display_waveform+0x83>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <amplitude2signal@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    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1170 <oled_display_waveform+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   $0x5f,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     121c <oled_display_waveform+0xec>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <amplitude2signal@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    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11db <oled_display_waveform+0xab>
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_waveform>:
push   %r14
push   %rbx
sub    $0x28,%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    $0x5f,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%edi
call   1040 <amplitude2signal@plt>
movzbl %al,%esi
mov    $0x40,%edi
call   1050 <OSD9616_send@plt>
add    $0xffffffffffffffff,%rbx
jb     1170 <oled_display_waveform+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    $0x5f,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%edi
call   1040 <amplitude2signal@plt>
sar    $0x8,%eax
mov    $0x40,%edi
mov    %eax,%esi
call   1050 <OSD9616_send@plt>
add    $0xffffffffffffffff,%rbx
jb     11c0 <oled_display_waveform+0x90>
movaps 0xe1b(%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 0xded(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <OSD9616_multiSend@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @oled_display_waveform(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 95, i32* %4
br label %11
11: ; preds = %25, %1
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %28
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 @amplitude2signal(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)
br label %25
25: ; preds = %14
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
br label %11
28: ; preds = %11
%29 = call i32 @OSD9616_send(i32 0, i32 0)
%30 = call i32 @OSD9616_send(i32 0, i32 16)
%31 = call i32 @OSD9616_send(i32 0, i32 177)
store i32 95, i32* %4
br label %32
32: ; preds = %46, %28
%33 = load i32, i32* %4
%34 = icmp sge i32 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %32
%36 = load i32*, i32** %2
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 @amplitude2signal(i32 %40)
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = ashr i32 %42, 8
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = call i32 @OSD9616_send(i32 64, i32 %44)
br label %46
46: ; preds = %35
%47 = load i32, i32* %4
%48 = add nsw i32 %47, -1
store i32 %48, i32* %4
br label %32
49: ; preds = %32
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %50
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 41, i32* %51
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 0, i32* %52
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 0, i32* %53
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
store i32 3, i32* %54
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
store i32 1, i32* %55
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
store i32 1, i32* %56
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%58 = call i32 @OSD9616_multiSend(i32* %57, i32 7)
%59 = call i32 @OSD9616_send(i32 0, i32 46)
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 0, i32* %60
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 163, i32* %61
%62 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 8, i32* %62
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 8, i32* %63
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%65 = call i32 @OSD9616_multiSend(i32* %64, i32 4)
ret i32 0
}

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