#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*/ O_WRONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int write(int, short *, int);
int main(int rgc, char *argv[]) {
  int fp, i, cnt;
  short buf[1024];
  fp = open("/dev/usrp1_e0", O_WRONLY);
  printf("fp = %d\n", fp);
  for (i = 0; i < 1024; i++) {
    buf[i] = i;
  }
  cnt = write(fp, buf, 2048);
  printf("Bytes written - %d\n", cnt);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jge    11a4 <main+0x74>
mov    -0x18(%rbp),%eax
mov    %ax,%cx
movslq -0x18(%rbp),%rax
mov    %cx,-0x820(%rbp,%rax,2)
ff
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1177 <main+0x47>
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x800,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xf48(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
lea    0xf48(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movdqa 0xe9b(%rip),%xmm0
xor    %eax,%eax
movdqa 0xea0(%rip),%xmm8
movdqa 0xea7(%rip),%xmm9
movdqa 0xeae(%rip),%xmm10
movdqa 0xeb6(%rip),%xmm4
movdqa 0xebe(%rip),%xmm5
movdqa 0xec6(%rip),%xmm6
movdqa 0xece(%rip),%xmm7
movdqa 0xed6(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm2
paddw  %xmm8,%xmm2
movdqa %xmm0,(%rsp,%rax,2)
movdqa %xmm2,0x10(%rsp,%rax,2)
movdqa %xmm0,%xmm2
paddw  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddw  %xmm10,%xmm3
movdqa %xmm2,0x20(%rsp,%rax,2)
movdqa %xmm3,0x30(%rsp,%rax,2)
movdqa %xmm0,%xmm2
paddw  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddw  %xmm5,%xmm3
movdqa %xmm2,0x40(%rsp,%rax,2)
movdqa %xmm3,0x50(%rsp,%rax,2)
movdqa %xmm0,%xmm2
paddw  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddw  %xmm7,%xmm3
movdqa %xmm2,0x60(%rsp,%rax,2)
movdqa %xmm3,0x70(%rsp,%rax,2)
add    $0x40,%rax
paddw  %xmm1,%xmm0
cmp    $0x400,%rax
jne    11b0 <main+0x80>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x800,%edx
call   1030 <write@plt>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/dev/usrp1_e0\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"fp = %d\0A\00"
@.str.2 = [20 x i8] c"Bytes written - %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i16]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @O_WRONLY
%11 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 0, i32* %7
br label %14
14: ; preds = %23, %2
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 1024
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i32, i32* %7
%19 = trunc i32 %18 to i16
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i16], [1024 x i16]* %9, i64 0, i64 %21
store i16 %19, i16* %22
br label %23
23: ; preds = %17
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %14
26: ; preds = %14
%27 = load i32, i32* %6
%28 = getelementptr inbounds [1024 x i16], [1024 x i16]* %9, i64 0, i64 0
%29 = call i32 @write(i32 %27, i16* %28, i32 2048)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [14 x i8] c"/dev/usrp1_e0\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"fp = %d\0A\00"
@.str.2 = [20 x i8] c"Bytes written - %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i16]
%4 = bitcast [1024 x i16]* %3 to i8*
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %8, %2
%9 = phi i64 [ 0, %2 ], [ %37, %8 ]
%10 = phi <8 x i16> [ <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, %2 ], [ %38, %8 ]
%11 = add <8 x i16> %10, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8>
%12 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 %9
%13 = bitcast i16* %12 to <8 x i16>*
store <8 x i16> %10, <8 x i16>* %13
%14 = getelementptr inbounds i16, i16* %12, i64 8
%15 = bitcast i16* %14 to <8 x i16>*
store <8 x i16> %11, <8 x i16>* %15
%16 = or i64 %9, 16
%17 = add <8 x i16> %10, <i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16>
%18 = add <8 x i16> %10, <i16 24, i16 24, i16 24, i16 24, i16 24, i16 24, i16 24, i16 24>
%19 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 %16
%20 = bitcast i16* %19 to <8 x i16>*
store <8 x i16> %17, <8 x i16>* %20
%21 = getelementptr inbounds i16, i16* %19, i64 8
%22 = bitcast i16* %21 to <8 x i16>*
store <8 x i16> %18, <8 x i16>* %22
%23 = or i64 %9, 32
%24 = add <8 x i16> %10, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
%25 = add <8 x i16> %10, <i16 40, i16 40, i16 40, i16 40, i16 40, i16 40, i16 40, i16 40>
%26 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 %23
%27 = bitcast i16* %26 to <8 x i16>*
store <8 x i16> %24, <8 x i16>* %27
%28 = getelementptr inbounds i16, i16* %26, i64 8
%29 = bitcast i16* %28 to <8 x i16>*
store <8 x i16> %25, <8 x i16>* %29
%30 = or i64 %9, 48
%31 = add <8 x i16> %10, <i16 48, i16 48, i16 48, i16 48, i16 48, i16 48, i16 48, i16 48>
%32 = add <8 x i16> %10, <i16 56, i16 56, i16 56, i16 56, i16 56, i16 56, i16 56, i16 56>
%33 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 %30
%34 = bitcast i16* %33 to <8 x i16>*
store <8 x i16> %31, <8 x i16>* %34
%35 = getelementptr inbounds i16, i16* %33, i64 8
%36 = bitcast i16* %35 to <8 x i16>*
store <8 x i16> %32, <8 x i16>* %36
%37 = add nuw nsw i64 %9, 64
%38 = add <8 x i16> %10, <i16 64, i16 64, i16 64, i16 64, i16 64, i16 64, i16 64, i16 64>
%39 = icmp eq i64 %37, 1024
br i1 %39, label %40, label %8
40: ; preds = %8
%41 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 0
%42 = call i32 @write(i32 %6, i16* %41, i32 2048)
%43 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %42)
ret i32 0
}