#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*/ doReset();
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ writeByte(int);
int globalStartConversion(void) {
  int retry = 0;
  int maxloop;
  while (retry < 10) {
    if (!doReset())
      usleep(10000);
    else {
      writeByte(0xCC);
      writeByte(0x44);
      maxloop = 0;
      usleep(750000);
      return 1;
    }
    retry++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<globalStartConversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11a7 <globalStartConversion+0x77>
mov    $0x0,%al
call   1030 <doReset@plt>
cmp    $0x0,%eax
jne    1168 <globalStartConversion+0x38>
mov    $0x2710,%edi
call   1050 <usleep@plt>
jmp    1199 <globalStartConversion+0x69>
mov    $0xcc,%edi
call   1040 <writeByte@plt>
mov    $0x44,%edi
call   1040 <writeByte@plt>
movl   $0x0,-0xc(%rbp)
mov    $0xb71b0,%edi
call   1050 <usleep@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ae <globalStartConversion+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113f <globalStartConversion+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<globalStartConversion>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%ebx
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
jne    1212 <globalStartConversion+0xe2>
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1030 <doReset@plt>
test   %eax,%eax
je     1230 <globalStartConversion+0x100>
mov    $0xcc,%edi
call   1040 <writeByte@plt>
mov    $0x44,%edi
call   1040 <writeByte@plt>
mov    $0x1,%ebp
mov    $0xb71b0,%ebx
mov    %ebx,%edi
call   1050 <usleep@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @globalStartConversion() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = call i32 (...) @doReset()
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @usleep(i32 10000)
br label %16
12: ; preds = %7
%13 = call i32 @writeByte(i32 204)
%14 = call i32 @writeByte(i32 68)
store i32 0, i32* %3
%15 = call i32 @usleep(i32 750000)
store i32 1, i32* %1
br label %20
16: ; preds = %10
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
store i32 0, i32* %1
br label %20
20: ; preds = %19, %12
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
define i32 @globalStartConversion() {
%1 = tail call i32 (...) @doReset()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %39
3: ; preds = %0
%4 = tail call i32 @usleep(i32 10000)
%5 = tail call i32 (...) @doReset()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %39
7: ; preds = %3
%8 = tail call i32 @usleep(i32 10000)
%9 = tail call i32 (...) @doReset()
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %39
11: ; preds = %7
%12 = tail call i32 @usleep(i32 10000)
%13 = tail call i32 (...) @doReset()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = tail call i32 @usleep(i32 10000)
%17 = tail call i32 (...) @doReset()
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = tail call i32 @usleep(i32 10000)
%21 = tail call i32 (...) @doReset()
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %39
23: ; preds = %19
%24 = tail call i32 @usleep(i32 10000)
%25 = tail call i32 (...) @doReset()
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = tail call i32 @usleep(i32 10000)
%29 = tail call i32 (...) @doReset()
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = tail call i32 @usleep(i32 10000)
%33 = tail call i32 (...) @doReset()
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = tail call i32 @usleep(i32 10000)
%37 = tail call i32 (...) @doReset()
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %35, %31, %27, %23, %19, %15, %11, %7, %3, %0
%40 = tail call i32 @writeByte(i32 204)
%41 = tail call i32 @writeByte(i32 68)
br label %42
42: ; preds = %35, %39
%43 = phi i32 [ 750000, %39 ], [ 10000, %35 ]
%44 = phi i32 [ 1, %39 ], [ 0, %35 ]
%45 = tail call i32 @usleep(i32 %43)
ret i32 %44
}