#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*/ gds_swap2bytes(unsigned char *);
int /*<<< orphan*/ write(int, ...);
void gds_write_units(int fd, float dbu_uu, float dbu_m) {
  short int count, token;
  int i;
  unsigned char db_units[] = {0x3e, 0x41, 0x89, 0x37, 0x4b, 0xc6, 0xa7, 0xf0};
  unsigned char user_units[] = {0x39, 0x44, 0xb8, 0x2f, 0xa0, 0x9b, 0x5a, 0x54};
  count = 20;
  gds_swap2bytes((unsigned char *)&count);
  write(fd, &count, 2);
  token = 0x0305;
  gds_swap2bytes((unsigned char *)&token);
  write(fd, &token, 2);
  for (i = 0; i < 8; i++) {
    write(fd, &(db_units[i]), 1);
  }
  for (i = 0; i < 8; i++) {
    write(fd, &(user_units[i]), 1);
  }
}


x86 assembly (clang, -O0):
<gds_write_units>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x24(%rbp)
movw   $0x14,-0xe(%rbp)
lea    -0xe(%rbp),%rdi
call   1040 <gds_swap2bytes@plt>
mov    -0x4(%rbp),%edi
lea    -0xe(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <write@plt>
movw   $0x305,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <gds_swap2bytes@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11c8 <gds_write_units+0xa8>
mov    -0x4(%rbp),%edi
movslq -0x14(%rbp),%rax
lea    -0x1c(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <gds_write_units+0x76>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1201 <gds_write_units+0xe1>
mov    -0x4(%rbp),%edi
movslq -0x14(%rbp),%rax
lea    -0x24(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cf <gds_write_units+0xaf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gds_write_units>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
movabs $0xf0a7c64b3789413e,%rax
c6 a7 f0
mov    %rax,0x8(%rsp)
movabs $0x545a9ba02fb84439,%rax
9b 5a 54
mov    %rax,(%rsp)
movw   $0x14,0x16(%rsp)
lea    0x16(%rsp),%r14
mov    %r14,%rdi
call   1040 <gds_swap2bytes@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <write@plt>
movw   $0x305,0x14(%rsp)
lea    0x14(%rsp),%r14
mov    %r14,%rdi
call   1040 <gds_swap2bytes@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x9(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xa(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xb(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xf(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x1(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x2(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x3(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x5(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x6(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.gds_write_units.db_units = [8 x i8] c">A\897K\C6\A7\F0"
@__const.gds_write_units.user_units = [8 x i8] c"9D\B8/\A0\9BZT"
define void @gds_write_units(i32 %0, float %1, float %2) {
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca i16
%8 = alloca i16
%9 = alloca i32
%10 = alloca [8 x i8]
%11 = alloca [8 x i8]
store i32 %0, i32* %4
store float %1, float* %5
store float %2, float* %6
%12 = bitcast [8 x i8]* %10 to i8*
%13 = bitcast [8 x i8]* %11 to i8*
store i16 20, i16* %7
%14 = bitcast i16* %7 to i8*
%15 = call i32 @gds_swap2bytes(i8* %14)
%16 = load i32, i32* %4
%17 = call i32 (i32, ...) @write(i32 %16, i16* %7, i32 2)
store i16 773, i16* %8
%18 = bitcast i16* %8 to i8*
%19 = call i32 @gds_swap2bytes(i8* %18)
%20 = load i32, i32* %4
%21 = call i32 (i32, ...) @write(i32 %20, i16* %8, i32 2)
store i32 0, i32* %9
br label %22
22: ; preds = %31, %3
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 8
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %4
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 %28
%30 = call i32 (i32, ...) @write(i32 %26, i8* %29, i32 1)
br label %31
31: ; preds = %25
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %22
34: ; preds = %22
store i32 0, i32* %9
br label %35
35: ; preds = %44, %34
%36 = load i32, i32* %9
%37 = icmp slt i32 %36, 8
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = load i32, i32* %4
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 %41
%43 = call i32 (i32, ...) @write(i32 %39, i8* %42, i32 1)
br label %44
44: ; preds = %38
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %35
47: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @gds_write_units(i32 %0, float %1, float %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i64
%7 = bitcast i64* %6 to [8 x i8]*
%8 = alloca i64
%9 = bitcast i16* %4 to i8*
%10 = bitcast i16* %5 to i8*
%11 = bitcast i64* %6 to i8*
store i64 -1105697157139578562, i64* %6
%12 = bitcast i64* %8 to i8*
store i64 6078341759387583545, i64* %8
store i16 20, i16* %4
%13 = call i32 @gds_swap2bytes(i8* %9)
%14 = call i32 (i32, ...) @write(i32 %0, i16* %4, i32 2)
store i16 773, i16* %5
%15 = call i32 @gds_swap2bytes(i8* %10)
%16 = call i32 (i32, ...) @write(i32 %0, i16* %5, i32 2)
%17 = call i32 (i32, ...) @write(i32 %0, i64* %6, i32 1)
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 1
%19 = call i32 (i32, ...) @write(i32 %0, i8* %18, i32 1)
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
%21 = call i32 (i32, ...) @write(i32 %0, i8* %20, i32 1)
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 3
%23 = call i32 (i32, ...) @write(i32 %0, i8* %22, i32 1)
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 4
%25 = call i32 (i32, ...) @write(i32 %0, i8* %24, i32 1)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 5
%27 = call i32 (i32, ...) @write(i32 %0, i8* %26, i32 1)
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 6
%29 = call i32 (i32, ...) @write(i32 %0, i8* %28, i32 1)
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 7
%31 = call i32 (i32, ...) @write(i32 %0, i8* %30, i32 1)
%32 = bitcast i64* %8 to [8 x i8]*
%33 = call i32 (i32, ...) @write(i32 %0, i64* %8, i32 1)
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 1
%35 = call i32 (i32, ...) @write(i32 %0, i8* %34, i32 1)
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 2
%37 = call i32 (i32, ...) @write(i32 %0, i8* %36, i32 1)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 3
%39 = call i32 (i32, ...) @write(i32 %0, i8* %38, i32 1)
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 4
%41 = call i32 (i32, ...) @write(i32 %0, i8* %40, i32 1)
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 5
%43 = call i32 (i32, ...) @write(i32 %0, i8* %42, i32 1)
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 6
%45 = call i32 (i32, ...) @write(i32 %0, i8* %44, i32 1)
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %32, i64 0, i64 7
%47 = call i32 (i32, ...) @write(i32 %0, i8* %46, i32 1)
ret void
}