#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*/ lcm_init();
int /*<<< orphan*/ lcm_reset();
int /*<<< orphan*/ printk(char *, ...);
int read_data_cmd();
int /*<<< orphan*/ send_ctrl_cmd(int);
int /*<<< orphan*/ send_data_cmd(int);
unsigned int lcm_compare_id() {
  int para1, para2, para3, para4, para5;
  int adc_ret = 0;
  lcm_reset();
  send_ctrl_cmd(0xB0);
  send_data_cmd(0x00);
  send_ctrl_cmd(0xBF);
  para1 = read_data_cmd();
  para2 = read_data_cmd();
  para3 = read_data_cmd();
  para4 = read_data_cmd();
  para5 = read_data_cmd();
  if (para1 == 0xBF || para1 == 0x00) {
    printk("r61581 LCD read id RESET \n");
    lcm_init();
    send_ctrl_cmd(0xB0);
    send_data_cmd(0x00);
    send_ctrl_cmd(0xBF);
    para1 = read_data_cmd();
    para2 = read_data_cmd();
    para3 = read_data_cmd();
    para4 = read_data_cmd();
    para5 = read_data_cmd();
  }
  printk("r61581 LCD read id1 = %x \n", para1);
  printk("r61581 LCD read id2 = %x \n", para2);
  printk("r61581 LCD read id3 = %x \n", para3);
  printk("r61581 LCD read id4 = %x \n", para4);
  printk("r61581 LCD read id5 = %x \n", para5);
  para2 = para2 & 0xFF;
  para3 = para3 & 0xFF;
  para4 = para4 & 0xFF;
  para5 = para5 & 0xFF;
  if ((para4 == 0x15) && (para5 == 0x81))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<lcm_compare_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <lcm_reset@plt>
mov    $0xb0,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %edi,%edi
call   1060 <send_data_cmd@plt>
mov    $0xbf,%edi
call   1080 <send_ctrl_cmd@plt>
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xbf,-0x8(%rbp)
je     11da <lcm_compare_id+0x7a>
cmpl   $0x0,-0x8(%rbp)
jne    123c <lcm_compare_id+0xdc>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    $0x0,%al
call   1070 <lcm_init@plt>
mov    $0xb0,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %edi,%edi
call   1060 <send_data_cmd@plt>
mov    $0xbf,%edi
call   1080 <send_ctrl_cmd@plt>
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <read_data_cmd@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0xc(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x10(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x14(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x18(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x15,-0x14(%rbp)
jne    12e0 <lcm_compare_id+0x180>
cmpl   $0x81,-0x18(%rbp)
jne    12e0 <lcm_compare_id+0x180>
movl   $0x1,-0x4(%rbp)
jmp    12e7 <lcm_compare_id+0x187>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcm_compare_id>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1040 <lcm_reset@plt>
mov    $0xb0,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %edi,%edi
call   1060 <send_data_cmd@plt>
mov    $0xbf,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
cmp    $0xbf,%ebx
je     11c4 <lcm_compare_id+0x64>
test   %ebx,%ebx
jne    1222 <lcm_compare_id+0xc2>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1030 <printk@plt>
xor    %eax,%eax
call   1070 <lcm_init@plt>
mov    $0xb0,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %edi,%edi
call   1060 <send_data_cmd@plt>
mov    $0xbf,%edi
call   1080 <send_ctrl_cmd@plt>
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <read_data_cmd@plt>
mov    %eax,%ebp
lea    0xdf0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printk@plt>
lea    0xdfb(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printk@plt>
lea    0xe05(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printk@plt>
lea    0xe0f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printk@plt>
lea    0xe19(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printk@plt>
movzbl %r12b,%ecx
movzbl %bpl,%edx
xor    $0x15,%ecx
xor    $0x81,%edx
xor    %eax,%eax
or     %ecx,%edx
sete   %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"r61581 LCD read id RESET \0A\00"
@.str.1 = [27 x i8] c"r61581 LCD read id1 = %x \0A\00"
@.str.2 = [27 x i8] c"r61581 LCD read id2 = %x \0A\00"
@.str.3 = [27 x i8] c"r61581 LCD read id3 = %x \0A\00"
@.str.4 = [27 x i8] c"r61581 LCD read id4 = %x \0A\00"
@.str.5 = [27 x i8] c"r61581 LCD read id5 = %x \0A\00"
define i32 @lcm_compare_id() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %7
%8 = call i32 (...) @lcm_reset()
%9 = call i32 @send_ctrl_cmd(i32 176)
%10 = call i32 @send_data_cmd(i32 0)
%11 = call i32 @send_ctrl_cmd(i32 191)
%12 = call i32 (...) @read_data_cmd()
store i32 %12, i32* %2
%13 = call i32 (...) @read_data_cmd()
store i32 %13, i32* %3
%14 = call i32 (...) @read_data_cmd()
store i32 %14, i32* %4
%15 = call i32 (...) @read_data_cmd()
store i32 %15, i32* %5
%16 = call i32 (...) @read_data_cmd()
store i32 %16, i32* %6
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 191
br i1 %18, label %22, label %19
19: ; preds = %0
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %19, %0
%23 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (...) @lcm_init()
%25 = call i32 @send_ctrl_cmd(i32 176)
%26 = call i32 @send_data_cmd(i32 0)
%27 = call i32 @send_ctrl_cmd(i32 191)
%28 = call i32 (...) @read_data_cmd()
store i32 %28, i32* %2
%29 = call i32 (...) @read_data_cmd()
store i32 %29, i32* %3
%30 = call i32 (...) @read_data_cmd()
store i32 %30, i32* %4
%31 = call i32 (...) @read_data_cmd()
store i32 %31, i32* %5
%32 = call i32 (...) @read_data_cmd()
store i32 %32, i32* %6
br label %33
33: ; preds = %22, %19
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %3
%45 = and i32 %44, 255
store i32 %45, i32* %3
%46 = load i32, i32* %4
%47 = and i32 %46, 255
store i32 %47, i32* %4
%48 = load i32, i32* %5
%49 = and i32 %48, 255
store i32 %49, i32* %5
%50 = load i32, i32* %6
%51 = and i32 %50, 255
store i32 %51, i32* %6
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 21
br i1 %53, label %54, label %58
54: ; preds = %33
%55 = load i32, i32* %6
%56 = icmp eq i32 %55, 129
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 1, i32* %1
br label %59
58: ; preds = %54, %33
store i32 0, i32* %1
br label %59
59: ; preds = %58, %57
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [27 x i8] c"r61581 LCD read id RESET \0A\00"
@.str.1 = [27 x i8] c"r61581 LCD read id1 = %x \0A\00"
@.str.2 = [27 x i8] c"r61581 LCD read id2 = %x \0A\00"
@.str.3 = [27 x i8] c"r61581 LCD read id3 = %x \0A\00"
@.str.4 = [27 x i8] c"r61581 LCD read id4 = %x \0A\00"
@.str.5 = [27 x i8] c"r61581 LCD read id5 = %x \0A\00"
define i32 @lcm_compare_id() {
%1 = tail call i32 (...) @lcm_reset()
%2 = tail call i32 @send_ctrl_cmd(i32 176)
%3 = tail call i32 @send_data_cmd(i32 0)
%4 = tail call i32 @send_ctrl_cmd(i32 191)
%5 = tail call i32 (...) @read_data_cmd()
%6 = tail call i32 (...) @read_data_cmd()
%7 = tail call i32 (...) @read_data_cmd()
%8 = tail call i32 (...) @read_data_cmd()
%9 = tail call i32 (...) @read_data_cmd()
switch i32 %5, label %21 [
i32 191, label %10
i32 0, label %10
]
10: ; preds = %0, %0
%11 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (...) @lcm_init()
%13 = tail call i32 @send_ctrl_cmd(i32 176)
%14 = tail call i32 @send_data_cmd(i32 0)
%15 = tail call i32 @send_ctrl_cmd(i32 191)
%16 = tail call i32 (...) @read_data_cmd()
%17 = tail call i32 (...) @read_data_cmd()
%18 = tail call i32 (...) @read_data_cmd()
%19 = tail call i32 (...) @read_data_cmd()
%20 = tail call i32 (...) @read_data_cmd()
br label %21
21: ; preds = %0, %10
%22 = phi i32 [ %16, %10 ], [ %5, %0 ]
%23 = phi i32 [ %17, %10 ], [ %6, %0 ]
%24 = phi i32 [ %18, %10 ], [ %7, %0 ]
%25 = phi i32 [ %19, %10 ], [ %8, %0 ]
%26 = phi i32 [ %20, %10 ], [ %9, %0 ]
%27 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%28 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%29 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%30 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%31 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%32 = and i32 %25, 255
%33 = and i32 %26, 255
%34 = icmp eq i32 %32, 21
%35 = icmp eq i32 %33, 129
%36 = select i1 %34, i1 %35, i1 false
%37 = zext i1 %36 to i32
ret i32 %37
}