#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 */
scalar_t__ findone(int, char, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ writebuf(int, unsigned char *, int);
void perform_status(int fd) {
  unsigned char out[4];
  memset(out, 0, sizeof(out));
  ((out)[0]) = (0x80 | 3);
  writebuf(fd, out, sizeof(out));
  if (findone(fd, '\0', 5000 * 1000) <= 0)
    fprintf(stderr, "Error getting null during cmd\n");
}


x86 assembly (clang, -O0):
<perform_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movb   $0x83,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1050 <writebuf@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   1060 <findone@plt>
cmp    $0x0,%rax
jg     119e <perform_status+0x5e>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_status>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movb   $0x83,0x4(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <writebuf@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   1060 <findone@plt>
test   %rax,%rax
jg     1196 <perform_status+0x56>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Error getting null during cmd\0A\00"
define void @perform_status(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 4)
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 -125, i8* %6
%7 = load i32, i32* %2
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%9 = call i32 @writebuf(i32 %7, i8* %8, i32 4)
%10 = load i32, i32* %2
%11 = call i64 @findone(i32 %10, i8 signext 0, i32 5000000)
%12 = icmp sle 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 null during cmd\0A\00"
define void @perform_status(i32 %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 4)
store i8 -125, i8* %3
%5 = call i32 @writebuf(i32 %0, i8* %3, i32 4)
%6 = call i64 @findone(i32 %0, i8 signext 0, i32 5000000)
%7 = icmp slt i64 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %1
ret void
}