#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_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, short);
int read(int, short *, int);
int main(int rgc, char *argv[]) {
  int fp, cnt;
  short buf[1024];
  fp = open("/dev/usrp1_e0", O_RDONLY);
  printf("fp = %d\n", fp);
  do {
    cnt = read(fp, buf, 2048);
  } while (1);
  printf("Data - %hX\n", buf[0]);
}


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    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
lea    0xea3(%rip),%rdi
movswl %ax,%esi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1173 <main+0x43>
jmp    1199 <main+0x69>
lea    0xe77(%rip),%rdi
movswl -0x820(%rbp),%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
movswl %bx,%esi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x800,%edx
call   1040 <read@plt>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [14 x i8] c"/dev/usrp1_e0\00"
@O_RDONLY = global i32 0
@.str.1 = [9 x i8] c"fp = %d\0A\00"
@.str.2 = [12 x i8] c"Data - %hX\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 [1024 x i16]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = trunc i32 %11 to i16
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i16 signext %12)
br label %14
14: ; preds = %18, %2
%15 = load i32, i32* %6
%16 = getelementptr inbounds [1024 x i16], [1024 x i16]* %8, i64 0, i64 0
%17 = call i32 @read(i32 %15, i16* %16, i32 2048)
store i32 %17, i32* %7
br label %18
18: ; preds = %14
br i1 true, label %14, label %19
19: ; preds = %18
%20 = getelementptr inbounds [1024 x i16], [1024 x i16]* %8, i64 0, i64 0
%21 = load i16, i16* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i16 signext %21)
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [14 x i8] c"/dev/usrp1_e0\00"
@O_RDONLY = global i32 0
@.str.1 = [9 x i8] c"fp = %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_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = trunc i32 %6 to i16
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i16 signext %7)
%9 = getelementptr inbounds [1024 x i16], [1024 x i16]* %3, i64 0, i64 0
br label %10
10: ; preds = %10, %2
%11 = call i32 @read(i32 %6, i16* %9, i32 2048)
br label %10
}