#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 cap1166_get_leds();
int /*<<< orphan*/ cap1166_leds(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sn3218_enable(int);
int /*<<< orphan*/ sn3218_monocolor(char *);
int /*<<< orphan*/ st7036_clear();
int /*<<< orphan*/ st7036_contrast(int);
int /*<<< orphan*/ st7036_cursor_blink(int);
int /*<<< orphan*/ st7036_cursor_on(int);
int /*<<< orphan*/ st7036_cursor_position(int, int);
int st7036_get_cursor_position();
int /*<<< orphan*/ st7036_get_lcd_buffer(char *, int);
int /*<<< orphan*/ st7036_lcd_buffer(char *);
int main() {
  unsigned char red[6], green[6], blue[6];
  int i, j;
  sn3218_enable(1);
  sn3218_monocolor("a0a0a0");
  st7036_clear();
  sleep(1);
  st7036_cursor_on(1);
  st7036_cursor_blink(1);
  st7036_contrast(40);
  st7036_cursor_position(4, 1);
  st7036_lcd_buffer("Hello World");
  sleep(1);
  st7036_cursor_position(0, 0);
  st7036_lcd_buffer("Top Left");
  i = st7036_get_cursor_position();
  printf("ANS = %i\n", i);
  st7036_cursor_position(4, 1);
  i = st7036_get_cursor_position();
  printf("ANS = %i\n", i);
  char bb[60];
  st7036_get_lcd_buffer(bb, sizeof bb);
  printf(":%s:\n", bb);
  i = cap1166_get_leds();
  printf("%i\n", i);
  cap1166_leds(0);
  i = cap1166_get_leds();
  printf("%i\n", i);
  cap1166_leds(21);
  i = cap1166_get_leds();
  printf("%i\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    $0x1,%edi
call   1060 <sn3218_enable@plt>
lea    0xe07(%rip),%rdi
call   10c0 <sn3218_monocolor@plt>
mov    $0x0,%al
call   10f0 <st7036_clear@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    $0x1,%edi
call   1080 <st7036_cursor_on@plt>
mov    $0x1,%edi
call   1090 <st7036_cursor_blink@plt>
mov    $0x28,%edi
call   10e0 <st7036_contrast@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10a0 <st7036_cursor_position@plt>
lea    0xdc4(%rip),%rdi
call   10b0 <st7036_lcd_buffer@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10a0 <st7036_cursor_position@plt>
lea    0xdb1(%rip),%rdi
call   10b0 <st7036_lcd_buffer@plt>
mov    $0x0,%al
call   1030 <st7036_get_cursor_position@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10a0 <st7036_cursor_position@plt>
mov    $0x0,%al
call   1030 <st7036_get_cursor_position@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x3c,%esi
call   1050 <st7036_get_lcd_buffer@plt>
lea    -0x60(%rbp),%rsi
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10d0 <cap1166_get_leds@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1040 <cap1166_leds@plt>
mov    $0x0,%al
call   10d0 <cap1166_get_leds@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x15,%edi
call   1040 <cap1166_leds@plt>
mov    $0x0,%al
call   10d0 <cap1166_get_leds@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    $0x1,%edi
call   1060 <sn3218_enable@plt>
lea    0xe0a(%rip),%rdi
call   10c0 <sn3218_monocolor@plt>
xor    %eax,%eax
call   10f0 <st7036_clear@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    $0x1,%edi
call   1080 <st7036_cursor_on@plt>
mov    $0x1,%edi
call   1090 <st7036_cursor_blink@plt>
mov    $0x28,%edi
call   10e0 <st7036_contrast@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10a0 <st7036_cursor_position@plt>
lea    0xdc7(%rip),%rdi
call   10b0 <st7036_lcd_buffer@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10a0 <st7036_cursor_position@plt>
lea    0xdb4(%rip),%rdi
call   10b0 <st7036_lcd_buffer@plt>
xor    %eax,%eax
call   1030 <st7036_get_cursor_position@plt>
lea    0xdaa(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   10a0 <st7036_cursor_position@plt>
xor    %eax,%eax
call   1030 <st7036_get_cursor_position@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1050 <st7036_get_lcd_buffer@plt>
lea    0xd6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10d0 <cap1166_get_leds@plt>
lea    0xd53(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   1040 <cap1166_leds@plt>
xor    %eax,%eax
call   10d0 <cap1166_get_leds@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x15,%edi
call   1040 <cap1166_leds@plt>
xor    %eax,%eax
call   10d0 <cap1166_get_leds@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"a0a0a0\00"
@.str.1 = [12 x i8] c"Hello World\00"
@.str.2 = [9 x i8] c"Top Left\00"
@.str.3 = [10 x i8] c"ANS = %i\0A\00"
@.str.4 = [6 x i8] c":%s:\0A\00"
@.str.5 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [60 x i8]
%7 = call i32 @sn3218_enable(i32 1)
%8 = call i32 @sn3218_monocolor(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @st7036_clear()
%10 = call i32 @sleep(i32 1)
%11 = call i32 @st7036_cursor_on(i32 1)
%12 = call i32 @st7036_cursor_blink(i32 1)
%13 = call i32 @st7036_contrast(i32 40)
%14 = call i32 @st7036_cursor_position(i32 4, i32 1)
%15 = call i32 @st7036_lcd_buffer(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @sleep(i32 1)
%17 = call i32 @st7036_cursor_position(i32 0, i32 0)
%18 = call i32 @st7036_lcd_buffer(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (...) @st7036_get_cursor_position()
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 @st7036_cursor_position(i32 4, i32 1)
%23 = call i32 (...) @st7036_get_cursor_position()
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [60 x i8], [60 x i8]* %6, i64 0, i64 0
%27 = call i32 @st7036_get_lcd_buffer(i8* %26, i32 60)
%28 = getelementptr inbounds [60 x i8], [60 x i8]* %6, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%30 = call i32 (...) @cap1166_get_leds()
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = call i32 @cap1166_leds(i32 0)
%34 = call i32 (...) @cap1166_get_leds()
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = call i32 @cap1166_leds(i32 21)
%38 = call i32 (...) @cap1166_get_leds()
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"a0a0a0\00"
@.str.1 = [12 x i8] c"Hello World\00"
@.str.2 = [9 x i8] c"Top Left\00"
@.str.3 = [10 x i8] c"ANS = %i\0A\00"
@.str.4 = [6 x i8] c":%s:\0A\00"
@.str.5 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca [60 x i8]
%2 = tail call i32 @sn3218_enable(i32 1)
%3 = tail call i32 @sn3218_monocolor(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @st7036_clear()
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @st7036_cursor_on(i32 1)
%7 = tail call i32 @st7036_cursor_blink(i32 1)
%8 = tail call i32 @st7036_contrast(i32 40)
%9 = tail call i32 @st7036_cursor_position(i32 4, i32 1)
%10 = tail call i32 @st7036_lcd_buffer(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @st7036_cursor_position(i32 0, i32 0)
%13 = tail call i32 @st7036_lcd_buffer(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 (...) @st7036_get_cursor_position()
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = tail call i32 @st7036_cursor_position(i32 4, i32 1)
%17 = tail call i32 (...) @st7036_get_cursor_position()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%20 = call i32 @st7036_get_lcd_buffer(i8* %19, i32 60)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%22 = call i32 (...) @cap1166_get_leds()
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = call i32 @cap1166_leds(i32 0)
%25 = call i32 (...) @cap1166_get_leds()
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = call i32 @cap1166_leds(i32 21)
%28 = call i32 (...) @cap1166_get_leds()
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %28)
ret i32 0
}