#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 hp5400_command_read_noverify(int, int, int, unsigned char *);
int /*<<< orphan*/ hp5400_command_write_noverify(int, int, unsigned char *,
                                                 int);
int /*<<< orphan*/ sanei_debug_BACKEND_NAME_call(int, char *);
int /*<<< orphan*/ sleep(int);
int WarmupLamp(int iHandle) {
  int i = 30;
  int couldRead;
  unsigned char dataVerify[0x02];
  unsigned char data0000[] = {0x01};
  unsigned char data0300[3];
  hp5400_command_write_noverify(iHandle, 0x0000, data0000, 1);
  do {
    hp5400_command_read_noverify(iHandle, 0x0300, 3, data0300);
    hp5400_command_write_noverify(iHandle, 0x0000, data0000, 1);
    couldRead = hp5400_command_read_noverify(iHandle, 0xc500, 0x02, dataVerify);
    if ((dataVerify[0] != 0) || (dataVerify[1] != 0))
      sleep(1);
  } while ((i-- > 0) && (couldRead >= 0) &&
           ((dataVerify[0] != 0) || (dataVerify[1] != 0)));
  if (i > 0)
    return 0;
  sanei_debug_BACKEND_NAME_call(32, "***WARNING*** Warmup lamp failed...\n");
  return -1;
}


x86 assembly (clang, -O0):
<WarmupLamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1e,-0xc(%rbp)
mov    0xea8(%rip),%al
mov    %al,-0x13(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x13(%rbp),%rdx
xor    %esi,%esi
mov    $0x1,%ecx
call   1030 <hp5400_command_write_noverify@plt>
mov    -0x8(%rbp),%edi
lea    -0x16(%rbp),%rcx
mov    $0x300,%esi
mov    $0x3,%edx
call   1060 <hp5400_command_read_noverify@plt>
mov    -0x8(%rbp),%edi
lea    -0x13(%rbp),%rdx
xor    %esi,%esi
mov    $0x1,%ecx
call   1030 <hp5400_command_write_noverify@plt>
mov    -0x8(%rbp),%edi
lea    -0x12(%rbp),%rcx
mov    $0xc500,%esi
mov    $0x2,%edx
call   1060 <hp5400_command_read_noverify@plt>
mov    %eax,-0x10(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x0,%eax
jne    11ca <WarmupLamp+0x8a>
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     11d4 <WarmupLamp+0x94>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    11d9 <WarmupLamp+0x99>
mov    -0xc(%rbp),%ecx
mov    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x17(%rbp)
jle    1226 <WarmupLamp+0xe6>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x17(%rbp)
jl     1226 <WarmupLamp+0xe6>
movzbl -0x12(%rbp),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x18(%rbp)
jne    1220 <WarmupLamp+0xe0>
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x18(%rbp)
mov    -0x18(%rbp),%al
mov    %al,-0x17(%rbp)
mov    -0x17(%rbp),%al
test   $0x1,%al
jne    116e <WarmupLamp+0x2e>
cmpl   $0x0,-0xc(%rbp)
jle    1247 <WarmupLamp+0x107>
movl   $0x0,-0x4(%rbp)
jmp    125f <WarmupLamp+0x11f>
mov    $0x20,%edi
lea    0xdae(%rip),%rsi
call   1040 <sanei_debug_BACKEND_NAME_call@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WarmupLamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
movb   $0x1,0x4(%rsp)
lea    0x4(%rsp),%r14
xor    %esi,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1030 <hp5400_command_write_noverify@plt>
mov    $0x1e,%eax
lea    0x5(%rsp),%r15
lea    0x2(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%r13d
mov    %ebx,%edi
mov    $0x300,%esi
mov    $0x3,%edx
mov    %r15,%rcx
call   1060 <hp5400_command_read_noverify@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1030 <hp5400_command_write_noverify@plt>
mov    %ebx,%edi
mov    $0xc500,%esi
mov    $0x2,%edx
mov    %r12,%rcx
call   1060 <hp5400_command_read_noverify@plt>
mov    %eax,%ebp
movzbl 0x2(%rsp),%eax
or     0x3(%rsp),%al
je     11d3 <WarmupLamp+0x93>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r13d,%eax
add    $0xffffffff,%eax
jae    11ea <WarmupLamp+0xaa>
test   %ebp,%ebp
js     11ea <WarmupLamp+0xaa>
movzbl 0x2(%rsp),%ecx
or     0x3(%rsp),%cl
jne    1180 <WarmupLamp+0x40>
xor    %eax,%eax
cmp    $0x1,%r13d
jg     1208 <WarmupLamp+0xc8>
lea    0xe07(%rip),%rsi
mov    $0x20,%edi
call   1040 <sanei_debug_BACKEND_NAME_call@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.WarmupLamp.data0000 = [1 x i8] c"\01"
@.str = [37 x i8] c"***WARNING*** Warmup lamp failed...\0A\00"
define i32 @WarmupLamp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i8]
%7 = alloca [1 x i8]
%8 = alloca [3 x i8]
store i32 %0, i32* %3
store i32 30, i32* %4
%9 = bitcast [1 x i8]* %7 to i8*
%10 = load i32, i32* %3
%11 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%12 = call i32 @hp5400_command_write_noverify(i32 %10, i32 0, i8* %11, i32 1)
br label %13
13: ; preds = %54, %1
%14 = load i32, i32* %3
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%16 = call i32 @hp5400_command_read_noverify(i32 %14, i32 768, i32 3, i8* %15)
%17 = load i32, i32* %3
%18 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%19 = call i32 @hp5400_command_write_noverify(i32 %17, i32 0, i8* %18, i32 1)
%20 = load i32, i32* %3
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%22 = call i32 @hp5400_command_read_noverify(i32 %20, i32 50432, i32 2, i8* %21)
store i32 %22, i32* %5
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %13
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27, %13
%33 = call i32 @sleep(i32 1)
br label %34
34: ; preds = %32, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, -1
store i32 %37, i32* %4
%38 = icmp sgt i32 %36, 0
br i1 %38, label %39, label %54
39: ; preds = %35
%40 = load i32, i32* %5
%41 = icmp sge i32 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %42
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br label %52
52: ; preds = %47, %42
%53 = phi i1 [ true, %42 ], [ %51, %47 ]
br label %54
54: ; preds = %52, %39, %35
%55 = phi i1 [ false, %39 ], [ false, %35 ], [ %53, %52 ]
br i1 %55, label %13, label %56
56: ; preds = %54
%57 = load i32, i32* %4
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %56
store i32 0, i32* %2
br label %62
60: ; preds = %56
%61 = call i32 @sanei_debug_BACKEND_NAME_call(i32 32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %62
62: ; preds = %60, %59
%63 = load i32, i32* %2
ret i32 %63
}

LLVM IR (-O2):
@.str = [37 x i8] c"***WARNING*** Warmup lamp failed...\0A\00"
define i32 @WarmupLamp(i32 %0) {
%2 = alloca [2 x i8]
%3 = alloca [1 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 1, i8* %6
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%8 = call i32 @hp5400_command_write_noverify(i32 %0, i32 0, i8* %6, i32 1)
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
br label %10
10: ; preds = %26, %1
%11 = phi i32 [ 30, %1 ], [ %27, %26 ]
%12 = call i32 @hp5400_command_read_noverify(i32 %0, i32 768, i32 3, i8* %7)
%13 = call i32 @hp5400_command_write_noverify(i32 %0, i32 0, i8* %6, i32 1)
%14 = call i32 @hp5400_command_read_noverify(i32 %0, i32 50432, i32 2, i8* %5)
%15 = load i8, i8* %5
%16 = icmp ne i8 %15, 0
%17 = load i8, i8* %9
%18 = icmp ne i8 %17, 0
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 @sleep(i32 1)
br label %22
22: ; preds = %20, %10
%23 = icmp ne i32 %11, 0
%24 = icmp sgt i32 %14, -1
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = add nsw i32 %11, -1
%28 = load i8, i8* %5
%29 = icmp ne i8 %28, 0
%30 = load i8, i8* %9
%31 = icmp ne i8 %30, 0
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %10, label %33
33: ; preds = %22, %26
%34 = icmp sgt i32 %11, 1
br i1 %34, label %37, label %35
35: ; preds = %33
%36 = call i32 @sanei_debug_BACKEND_NAME_call(i32 32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %33, %35
%38 = phi i32 [ -1, %35 ], [ 0, %33 ]
ret i32 %38
}