#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*/ die(char *);
int /*<<< orphan*/ flush_bytes(int);
int read_line(int, char *, int, int);
int /*<<< orphan*/ sleep(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write_line(int, char *);
void sync_interface(int devfd) {
  char buf[64];
  int i, ret;
  usleep(25000);
  flush_bytes(devfd);
  for (i = 0; i < 3; i++) {
    write_line(devfd, "");
    ret = read_line(devfd, buf, 64, 3000000);
    if (ret > 0 && strcmp(buf, "<E000") == 0)
      return;
    sleep(1);
  }
  die("error: can't establish communication with VRC0P interface\n");
}


x86 assembly (clang, -O0):
<sync_interface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x61a8,%edi
call   1090 <usleep@plt>
mov    -0x4(%rbp),%edi
call   1040 <flush_bytes@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    1207 <sync_interface+0x97>
mov    -0x4(%rbp),%edi
lea    0xe98(%rip),%rsi
call   1070 <write_line@plt>
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x40,%edx
mov    $0x2dc6c0,%ecx
call   1050 <read_line@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jle    11ef <sync_interface+0x7f>
lea    -0x50(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <sync_interface+0x7f>
jmp    1213 <sync_interface+0xa3>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1194 <sync_interface+0x24>
lea    0xdf8(%rip),%rdi
call   1060 <die@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sync_interface>:
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
mov    $0x61a8,%edi
call   1090 <usleep@plt>
mov    %ebx,%edi
call   1040 <flush_bytes@plt>
lea    0xeb1(%rip),%rsi
mov    %ebx,%edi
call   1070 <write_line@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x40,%edx
mov    $0x2dc6c0,%ecx
call   1050 <read_line@plt>
test   %eax,%eax
jle    11c6 <sync_interface+0x56>
lea    0xe4b(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1264 <sync_interface+0xf4>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe69(%rip),%rsi
mov    %ebx,%edi
call   1070 <write_line@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x40,%edx
mov    $0x2dc6c0,%ecx
call   1050 <read_line@plt>
test   %eax,%eax
jle    120a <sync_interface+0x9a>
lea    0xe03(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1264 <sync_interface+0xf4>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe25(%rip),%rsi
mov    %ebx,%edi
call   1070 <write_line@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x40,%edx
mov    $0x2dc6c0,%ecx
call   1050 <read_line@plt>
test   %eax,%eax
jle    124e <sync_interface+0xde>
lea    0xdbf(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1264 <sync_interface+0xf4>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xda7(%rip),%rdi
call   1060 <die@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"<E000\00"
@.str.2 = [59 x i8] c"error: can't establish communication with VRC0P interface\0A\00"
define void @sync_interface(i32 %0) {
%2 = alloca i32
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 @usleep(i32 25000)
%7 = load i32, i32* %2
%8 = call i32 @flush_bytes(i32 %7)
store i32 0, i32* %4
br label %9
9: ; preds = %27, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 @write_line(i32 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%17 = call i32 @read_line(i32 %15, i8* %16, i32 64, i32 3000000)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
br label %32
25: ; preds = %20, %12
%26 = call i32 @sleep(i32 1)
br label %27
27: ; preds = %25
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %9
30: ; preds = %9
%31 = call i32 @die(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"<E000\00"
@.str.2 = [59 x i8] c"error: can't establish communication with VRC0P interface\0A\00"
define void @sync_interface(i32 %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @usleep(i32 25000)
%5 = tail call i32 @flush_bytes(i32 %0)
%6 = call i32 @write_line(i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @read_line(i32 %0, i8* %3, i32 64, i32 3000000)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %9, %1
%13 = call i32 @sleep(i32 1)
%14 = call i32 @write_line(i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @read_line(i32 %0, i8* %3, i32 64, i32 3000000)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %17, %12
%21 = call i32 @sleep(i32 1)
%22 = call i32 @write_line(i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @read_line(i32 %0, i8* %3, i32 64, i32 3000000)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25, %20
%29 = call i32 @sleep(i32 1)
%30 = call i32 @die(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %9, %17, %25, %28
ret void
}