#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*/ deactivate_irq();
int get_touch_position(unsigned short *, unsigned short *);
int /*<<< orphan*/ lcd_clear_screen(int);
int /*<<< orphan*/ lcd_display_string_col_row(unsigned char *, int, int, int,
                                              int);
int /*<<< orphan*/ lcd_draw_dot(int, unsigned short, unsigned short);
int /*<<< orphan*/ lcd_draw_rect(int, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, unsigned short, unsigned short);
int /*<<< orphan*/ reactivate_irq();
void printPos(void) {
  unsigned short int x, y;
  deactivate_irq();
  if (get_touch_position(&x, &y) == 1) {
    printf("Touch event at postion x=%i y=%i \n", x, y);
    lcd_draw_dot(0XF800, x, y);
    if (x<130 & x> 60 & y < 20) {
      lcd_clear_screen(0X8430);
      lcd_draw_rect(0X0000, 60, 0, 130, 20);
      unsigned char str[16] = "press to clear!";
      lcd_display_string_col_row(str, 0XF800, 0X0000, 8, 0);
      unsigned char str2[11] = "draw here!";
      lcd_display_string_col_row(str2, 0X001F, 0X8430, 8, 10);
    }
  }
  reactivate_irq();
}


x86 assembly (clang, -O0):
<printPos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1040 <deactivate_irq@plt>
lea    -0x2(%rbp),%rdi
lea    -0x4(%rbp),%rsi
call   10a0 <get_touch_position@plt>
cmp    $0x1,%eax
jne    12a3 <printPos+0x123>
mov    -0x2(%rbp),%ax
lea    0xe50(%rip),%rdi
movzwl %ax,%esi
movzwl -0x4(%rbp),%edx
call   1030 <printf@plt>
mov    -0x2(%rbp),%ax
mov    $0xf800,%edi
movzwl %ax,%esi
movzwl -0x4(%rbp),%edx
call   1070 <lcd_draw_dot@plt>
movzwl -0x2(%rbp),%eax
cmp    $0x82,%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
movzwl -0x2(%rbp),%ecx
cmp    $0x3c,%ecx
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movzwl -0x4(%rbp),%ecx
cmp    $0x14,%ecx
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     129e <printPos+0x11e>
mov    $0x8430,%edi
call   1060 <lcd_clear_screen@plt>
xor    %edx,%edx
mov    $0x3c,%esi
mov    $0x82,%ecx
mov    $0x14,%r8d
mov    %edx,%edi
call   1090 <lcd_draw_rect@plt>
mov    0xdf7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xdf4(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xf800,%esi
xor    %r8d,%r8d
mov    $0x8,%ecx
mov    %r8d,%edx
call   1080 <lcd_display_string_col_row@plt>
mov    0xdbb(%rip),%rax
mov    %rax,-0x2b(%rbp)
mov    0xdb8(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xdb0(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2b(%rbp),%rdi
mov    $0x1f,%esi
mov    $0x8430,%edx
mov    $0x8,%ecx
mov    $0xa,%r8d
call   1080 <lcd_display_string_col_row@plt>
jmp    12a3 <printPos+0x123>
mov    $0x0,%al
call   1050 <reactivate_irq@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPos>:
sub    $0x38,%rsp
xor    %eax,%eax
call   1040 <deactivate_irq@plt>
lea    0xe(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <get_touch_position@plt>
cmp    $0x1,%eax
jne    1265 <printPos+0xe5>
movzwl 0xe(%rsp),%esi
movzwl 0xc(%rsp),%edx
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
movzwl 0xe(%rsp),%esi
movzwl 0xc(%rsp),%edx
mov    $0xf800,%edi
call   1070 <lcd_draw_dot@plt>
movzwl 0xe(%rsp),%eax
add    $0xffffffc3,%eax
cmp    $0x44,%ax
ja     1265 <printPos+0xe5>
cmpw   $0x13,0xc(%rsp)
ja     1265 <printPos+0xe5>
mov    $0x8430,%edi
call   1060 <lcd_clear_screen@plt>
xor    %edi,%edi
mov    $0x3c,%esi
xor    %edx,%edx
mov    $0x82,%ecx
mov    $0x14,%r8d
call   1090 <lcd_draw_rect@plt>
movaps 0xe1f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    $0xf800,%esi
xor    %edx,%edx
mov    $0x8,%ecx
xor    %r8d,%r8d
call   1080 <lcd_display_string_col_row@plt>
movabs $0x7265682077617264,%rax
68 65 72
mov    %rax,0x10(%rsp)
movl   $0x216572,0x17(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x1f,%esi
mov    $0x8430,%edx
mov    $0x8,%ecx
mov    $0xa,%r8d
call   1080 <lcd_display_string_col_row@plt>
xor    %eax,%eax
call   1050 <reactivate_irq@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Touch event at postion x=%i y=%i \0A\00"
@__const.printPos.str = [16 x i8] c"press to clear!\00"
@__const.printPos.str2 = [11 x i8] c"draw here!\00"
define void @printPos() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca [16 x i8]
%4 = alloca [11 x i8]
%5 = call i32 (...) @deactivate_irq()
%6 = call i32 @get_touch_position(i16* %1, i16* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %40
8: ; preds = %0
%9 = load i16, i16* %1
%10 = load i16, i16* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i16 zeroext %9, i16 zeroext %10)
%12 = load i16, i16* %1
%13 = load i16, i16* %2
%14 = call i32 @lcd_draw_dot(i32 63488, i16 zeroext %12, i16 zeroext %13)
%15 = load i16, i16* %1
%16 = zext i16 %15 to i32
%17 = icmp slt i32 %16, 130
%18 = zext i1 %17 to i32
%19 = load i16, i16* %1
%20 = zext i16 %19 to i32
%21 = icmp sgt i32 %20, 60
%22 = zext i1 %21 to i32
%23 = and i32 %18, %22
%24 = load i16, i16* %2
%25 = zext i16 %24 to i32
%26 = icmp slt i32 %25, 20
%27 = zext i1 %26 to i32
%28 = and i32 %23, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %8
%31 = call i32 @lcd_clear_screen(i32 33840)
%32 = call i32 @lcd_draw_rect(i32 0, i32 60, i32 0, i32 130, i32 20)
%33 = bitcast [16 x i8]* %3 to i8*
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%35 = call i32 @lcd_display_string_col_row(i8* %34, i32 63488, i32 0, i32 8, i32 0)
%36 = bitcast [11 x i8]* %4 to i8*
%37 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%38 = call i32 @lcd_display_string_col_row(i8* %37, i32 31, i32 33840, i32 8, i32 10)
br label %39
39: ; preds = %30, %8
br label %40
40: ; preds = %39, %0
%41 = call i32 (...) @reactivate_irq()
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Touch event at postion x=%i y=%i \0A\00"
@__const.printPos.str = [16 x i8] c"press to clear!\00"
@__const.printPos.str2 = [11 x i8] c"draw here!\00"
define void @printPos() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca [16 x i8]
%4 = alloca [11 x i8]
%5 = bitcast i16* %1 to i8*
%6 = bitcast i16* %2 to i8*
%7 = tail call i32 (...) @deactivate_irq()
%8 = call i32 @get_touch_position(i16* %1, i16* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %30
10: ; preds = %0
%11 = load i16, i16* %1
%12 = load i16, i16* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i16 zeroext %11, i16 zeroext %12)
%14 = load i16, i16* %1
%15 = load i16, i16* %2
%16 = call i32 @lcd_draw_dot(i32 63488, i16 zeroext %14, i16 zeroext %15)
%17 = load i16, i16* %1
%18 = add i16 %17, -61
%19 = icmp ult i16 %18, 69
%20 = load i16, i16* %2
%21 = icmp ult i16 %20, 20
%22 = and i1 %19, %21
br i1 %22, label %23, label %30
23: ; preds = %10
%24 = call i32 @lcd_clear_screen(i32 33840)
%25 = call i32 @lcd_draw_rect(i32 0, i32 60, i32 0, i32 130, i32 20)
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%27 = call i32 @lcd_display_string_col_row(i8* %26, i32 63488, i32 0, i32 8, i32 0)
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%29 = call i32 @lcd_display_string_col_row(i8* %28, i32 31, i32 33840, i32 8, i32 10)
br label %30
30: ; preds = %10, %23, %0
%31 = call i32 (...) @reactivate_irq()
ret void
}