#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*/ memset(unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned char, unsigned char, unsigned char);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, unsigned char *, int);
int init_mode(int fd) {
  int ret;
  unsigned char INIT[] = {0xFB, 0x00, 0X44, 0XFF, 0X66, 0X26};
  unsigned char RECV[10];
  memset(&RECV[0], 10, 0);
  write(fd, &INIT[0], 6);
  usleep(1000 * 200);
  read(fd, &RECV[0], 3);
  printf("init_mode:recv : %02x %02x %02x \n", RECV[0], RECV[1], RECV[2]);
  if (RECV[0] == 0x90 && RECV[1] == 0x00)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<init_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xe99(%rip),%ax
mov    %ax,-0xe(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x12(%rbp),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    $0x30d40,%edi
call   1070 <usleep@plt>
mov    -0x8(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x3,%edx
call   1060 <read@plt>
mov    -0x1c(%rbp),%cl
mov    -0x1b(%rbp),%al
lea    0xe4e(%rip),%rdi
movzbl %cl,%esi
movzbl %al,%edx
movzbl -0x1a(%rbp),%ecx
call   1040 <printf@plt>
movzbl -0x1c(%rbp),%eax
cmp    $0x90,%eax
jne    11ef <init_mode+0x9f>
movzbl -0x1b(%rbp),%eax
cmp    $0x0,%eax
jne    11ef <init_mode+0x9f>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <init_mode+0xa6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_mode>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
movw   $0x2666,0x14(%rsp)
movl   $0xff4400fb,0x10(%rsp)
ff
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1050 <memset@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <write@plt>
mov    $0x30d40,%edi
call   1070 <usleep@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3,%edx
call   1060 <read@plt>
movzbl 0x6(%rsp),%esi
movzbl 0x7(%rsp),%edx
movzbl 0x8(%rsp),%ecx
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    0x6(%rsp),%cl
xor    $0x90,%cl
xor    %eax,%eax
or     0x7(%rsp),%cl
setne  %al
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.init_mode.INIT = [6 x i8] c"\FB\00D\FFf&"
@.str = [34 x i8] c"init_mode:recv : %02x %02x %02x \0A\00"
define i32 @init_mode(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [6 x i8]
%6 = alloca [10 x i8]
store i32 %0, i32* %3
%7 = bitcast [6 x i8]* %5 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 10, i32 0)
%10 = load i32, i32* %3
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%12 = call i32 @write(i32 %10, i8* %11, i32 6)
%13 = call i32 @usleep(i32 200000)
%14 = load i32, i32* %3
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%16 = call i32 @read(i32 %14, i8* %15, i32 3)
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%18 = load i8, i8* %17
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 1
%20 = load i8, i8* %19
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 2
%22 = load i8, i8* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8 zeroext %18, i8 zeroext %20, i8 zeroext %22)
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = icmp eq i32 %26, 144
br i1 %27, label %28, label %34
28: ; preds = %1
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 1
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 0, i32* %2
br label %35
34: ; preds = %28, %1
store i32 1, i32* %2
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@__const.init_mode.INIT = [6 x i8] c"\FB\00D\FFf&"
@.str = [34 x i8] c"init_mode:recv : %02x %02x %02x \0A\00"
define i32 @init_mode(i32 %0) {
%2 = alloca [6 x i8]
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 10, i32 0)
%7 = call i32 @write(i32 %0, i8* %4, i32 6)
%8 = call i32 @usleep(i32 200000)
%9 = call i32 @read(i32 %0, i8* %5, i32 3)
%10 = load i8, i8* %5
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
%12 = load i8, i8* %11
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
%14 = load i8, i8* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8 zeroext %10, i8 zeroext %12, i8 zeroext %14)
%16 = load i8, i8* %5
%17 = icmp ne i8 %16, -112
%18 = load i8, i8* %11
%19 = icmp ne i8 %18, 0
%20 = select i1 %17, i1 true, i1 %19
%21 = zext i1 %20 to i32
ret i32 %21
}