#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 */
typedef int /*<<< orphan*/ out;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ getok(int, int, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int /*<<< orphan*/ raw_writebuf(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
void perform_sync(int fd) {
  unsigned char out[9];
  memset(out, 0xFF, sizeof(out));
  out[8] = 0;
  raw_writebuf(fd, out, sizeof(out));
  if (getok(fd, 5, 1000 * 1000) != 0)
    fprintf(stderr, "Error getting okay during cmd\n");
}


x86 assembly (clang, -O0):
<perform_sync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xd(%rbp),%rdi
mov    $0xff,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
movb   $0x0,-0x5(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x9,%edx
call   1040 <raw_writebuf@plt>
mov    -0x4(%rbp),%edi
mov    $0x5,%esi
mov    $0xf4240,%edx
call   1030 <getok@plt>
cmp    $0x0,%rax
je     11a4 <perform_sync+0x64>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_sync>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0xf(%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
movb   $0x0,0x17(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x9,%edx
call   1040 <raw_writebuf@plt>
mov    %ebx,%edi
mov    $0x5,%esi
mov    $0xf4240,%edx
call   1030 <getok@plt>
test   %rax,%rax
je     119f <perform_sync+0x5f>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Error getting okay during cmd\0A\00"
define void @perform_sync(i32 %0) {
%2 = alloca i32
%3 = alloca [9 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 255, i32 9)
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 8
store i8 0, i8* %6
%7 = load i32, i32* %2
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%9 = call i32 @raw_writebuf(i32 %7, i8* %8, i32 9)
%10 = load i32, i32* %2
%11 = call i64 @getok(i32 %10, i32 5, i32 1000000)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %1
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Error getting okay during cmd\0A\00"
define void @perform_sync(i32 %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 255, i32 9)
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 0, i8* %5
%6 = call i32 @raw_writebuf(i32 %0, i8* %3, i32 9)
%7 = call i64 @getok(i32 %0, i32 5, i32 1000000)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %1
ret void
}