#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*/ SEEK_SET;
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
unsigned char *malloc_aligned(int);
int write(int, unsigned char *, int);
int sendcmd(int f, int cmd, unsigned int arg1, unsigned int arg2,
            unsigned char arg3) {
  unsigned char *buff;
  buff = malloc_aligned(0x200);
  buff[0] = cmd;
  buff[1] = (arg1 >> 24) & 0xff;
  buff[2] = (arg1 >> 16) & 0xff;
  buff[3] = (arg1 >> 8) & 0xff;
  buff[4] = (arg1 >> 0) & 0xff;
  buff[5] = (arg2 >> 24) & 0xff;
  buff[6] = (arg2 >> 16) & 0xff;
  buff[7] = (arg2 >> 8) & 0xff;
  buff[8] = (arg2 >> 0) & 0xff;
  buff[9] = (arg3);
  lseek(f, 0x6200, SEEK_SET);
  return write(f, buff, 0x200);
}


x86 assembly (clang, -O0):
<sendcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    $0x200,%edi
call   1040 <malloc_aligned@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xc(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0xc(%rbp),%eax
shr    $0x0,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x10(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x10(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x10(%rbp),%eax
shr    $0x0,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x11(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x9(%rax)
mov    -0x4(%rbp),%edi
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
mov    $0x6200,%esi
call   1050 <lseek@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x200,%edx
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendcmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%ebx
mov    %esi,%r12d
mov    %edi,%r15d
mov    $0x200,%edi
call   1040 <malloc_aligned@plt>
mov    %rax,%rbp
mov    %r12b,(%rax)
mov    %ebx,%eax
shr    $0x18,%eax
mov    %al,0x1(%rbp)
mov    %ebx,%eax
shr    $0x10,%eax
mov    %al,0x2(%rbp)
mov    %bh,0x3(%rbp)
mov    %bl,0x4(%rbp)
mov    %r13d,%ecx
mov    %r13d,%eax
shr    $0x18,%eax
mov    %al,0x5(%rbp)
mov    %r13d,%eax
shr    $0x10,%eax
mov    %al,0x6(%rbp)
mov    %ch,0x7(%rbp)
mov    %cl,0x8(%rbp)
mov    %r14b,0x9(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    $0x6200,%esi
call   1050 <lseek@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @sendcmd(i32 %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8 %4, i8* %10
%12 = call i8* @malloc_aligned(i32 512)
store i8* %12, i8** %11
%13 = load i32, i32* %7
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %11
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 %14, i8* %16
%17 = load i32, i32* %8
%18 = lshr i32 %17, 24
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %11
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %20, i8* %22
%23 = load i32, i32* %8
%24 = lshr i32 %23, 16
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %11
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = load i32, i32* %8
%30 = lshr i32 %29, 8
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %11
%34 = getelementptr inbounds i8, i8* %33, i64 3
store i8 %32, i8* %34
%35 = load i32, i32* %8
%36 = lshr i32 %35, 0
%37 = and i32 %36, 255
%38 = trunc i32 %37 to i8
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i64 4
store i8 %38, i8* %40
%41 = load i32, i32* %9
%42 = lshr i32 %41, 24
%43 = and i32 %42, 255
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %11
%46 = getelementptr inbounds i8, i8* %45, i64 5
store i8 %44, i8* %46
%47 = load i32, i32* %9
%48 = lshr i32 %47, 16
%49 = and i32 %48, 255
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %11
%52 = getelementptr inbounds i8, i8* %51, i64 6
store i8 %50, i8* %52
%53 = load i32, i32* %9
%54 = lshr i32 %53, 8
%55 = and i32 %54, 255
%56 = trunc i32 %55 to i8
%57 = load i8*, i8** %11
%58 = getelementptr inbounds i8, i8* %57, i64 7
store i8 %56, i8* %58
%59 = load i32, i32* %9
%60 = lshr i32 %59, 0
%61 = and i32 %60, 255
%62 = trunc i32 %61 to i8
%63 = load i8*, i8** %11
%64 = getelementptr inbounds i8, i8* %63, i64 8
store i8 %62, i8* %64
%65 = load i8, i8* %10
%66 = load i8*, i8** %11
%67 = getelementptr inbounds i8, i8* %66, i64 9
store i8 %65, i8* %67
%68 = load i32, i32* %6
%69 = load i32, i32* @SEEK_SET
%70 = call i32 @lseek(i32 %68, i32 25088, i32 %69)
%71 = load i32, i32* %6
%72 = load i8*, i8** %11
%73 = call i32 @write(i32 %71, i8* %72, i32 512)
ret i32 %73
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @sendcmd(i32 %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4) {
%6 = tail call i8* @malloc_aligned(i32 512)
%7 = trunc i32 %1 to i8
store i8 %7, i8* %6
%8 = lshr i32 %2, 24
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %9, i8* %10
%11 = lshr i32 %2, 16
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %12, i8* %13
%14 = lshr i32 %2, 8
%15 = trunc i32 %14 to i8
%16 = getelementptr inbounds i8, i8* %6, i64 3
store i8 %15, i8* %16
%17 = trunc i32 %2 to i8
%18 = getelementptr inbounds i8, i8* %6, i64 4
store i8 %17, i8* %18
%19 = lshr i32 %3, 24
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %6, i64 5
store i8 %20, i8* %21
%22 = lshr i32 %3, 16
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %6, i64 6
store i8 %23, i8* %24
%25 = lshr i32 %3, 8
%26 = trunc i32 %25 to i8
%27 = getelementptr inbounds i8, i8* %6, i64 7
store i8 %26, i8* %27
%28 = trunc i32 %3 to i8
%29 = getelementptr inbounds i8, i8* %6, i64 8
store i8 %28, i8* %29
%30 = getelementptr inbounds i8, i8* %6, i64 9
store i8 %4, i8* %30
%31 = load i32, i32* @SEEK_SET
%32 = tail call i32 @lseek(i32 %0, i32 25088, i32 %31)
%33 = tail call i32 @write(i32 %0, i8* %6, i32 512)
ret i32 %33
}