#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 atoi(char *);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int getFreq(int fd, char vfo) {
  char cmd[4], response[15];
  int bytes, freq;
  sprintf(cmd, "F%c;", vfo);
  write(fd, cmd, strlen(cmd));
  usleep(600e3);
  bytes = read(fd, response, 14);
  response[14] = '\0';
  freq = atoi(response + 2);
  return freq;
}


x86 assembly (clang, -O0):
<getFreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
lea    -0x9(%rbp),%rdi
lea    0xe84(%rip),%rsi
movsbl -0x5(%rbp),%edx
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x9(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x927c0,%edi
call   1080 <usleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xe,%edx
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
movb   $0x0,-0xa(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFreq>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%edx
mov    %edi,%ebx
lea    0xe8e(%rip),%rsi
lea    0x5(%rsp),%r14
mov    %r14,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x927c0,%edi
call   1080 <usleep@plt>
lea    0x9(%rsp),%rsi
mov    %ebx,%edi
mov    $0xe,%edx
call   1050 <read@plt>
movb   $0x0,0x17(%rsp)
lea    0xb(%rsp),%rdi
call   1060 <atoi@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"F%c;\00"
define i32 @getFreq(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [4 x i8]
%6 = alloca [15 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %10)
%12 = load i32, i32* %3
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @write(i32 %12, i8* %13, i32 %15)
%17 = call i32 @usleep(i32 600000)
%18 = load i32, i32* %3
%19 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 14)
store i32 %20, i32* %7
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 14
store i8 0, i8* %21
%22 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"F%c;\00"
define i32 @getFreq(i32 %0, i8 signext %1) {
%3 = alloca [4 x i8]
%4 = alloca [15 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%7 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %1)
%8 = call i32 @strlen(i8* %5)
%9 = call i32 @write(i32 %0, i8* %5, i32 %8)
%10 = call i32 @usleep(i32 600000)
%11 = call i32 @read(i32 %0, i8* %6, i32 14)
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 14
store i8 0, i8* %12
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 2
%14 = call i32 @atoi(i8* %13)
ret i32 %14
}