#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*/ setFreq(int, char, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void setSplit(int fd, int hz, int hzUp) {
  char cmd[4];
  sprintf(cmd, "FR0;");
  write(fd, cmd, strlen(cmd));
  usleep(100e3);
  setFreq(fd, 'A', hz);
  if (hzUp == 0) {
    return;
  }
  sprintf(cmd, "FT1;");
  write(fd, cmd, strlen(cmd));
  usleep(100e3);
  setFreq(fd, 'B', hz + hzUp);
}


x86 assembly (clang, -O0):
<setSplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1070 <usleep@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x41,%esi
call   1050 <setFreq@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11bf <setSplit+0x6f>
jmp    1211 <setSplit+0xc1>
lea    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1070 <usleep@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
add    -0xc(%rbp),%edx
mov    $0x42,%esi
call   1050 <setFreq@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setSplit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
movb   $0x0,0x8(%rsp)
movl   $0x3b305246,0x4(%rsp)
3b
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
mov    %ebp,%edi
mov    $0x41,%esi
mov    %r14d,%edx
call   1050 <setFreq@plt>
test   %ebx,%ebx
je     11d2 <setSplit+0x92>
movb   $0x0,0x8(%rsp)
movl   $0x3b315446,0x4(%rsp)
3b
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
add    %r14d,%ebx
mov    %ebp,%edi
mov    $0x42,%esi
mov    %ebx,%edx
call   1050 <setFreq@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"FR0;\00"
@.str.1 = [5 x i8] c"FT1;\00"
define void @setSplit(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @write(i32 %10, i8* %11, i32 %13)
%15 = call i32 @usleep(i32 100000)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @setFreq(i32 %16, i8 signext 65, i32 %17)
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
br label %36
22: ; preds = %3
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %4
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @write(i32 %25, i8* %26, i32 %28)
%30 = call i32 @usleep(i32 100000)
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = add nsw i32 %32, %33
%35 = call i32 @setFreq(i32 %31, i8 signext 66, i32 %34)
br label %36
36: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"FR0;\00"
@.str.1 = [5 x i8] c"FT1;\00"
define void @setSplit(i32 %0, i32 %1, i32 %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
%7 = call i32 @write(i32 %0, i8* %5, i32 %6)
%8 = call i32 @usleep(i32 100000)
%9 = call i32 @setFreq(i32 %0, i8 signext 65, i32 %1)
%10 = icmp eq i32 %2, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = call i32 @strlen(i8* %5)
%13 = call i32 @write(i32 %0, i8* %5, i32 %12)
%14 = call i32 @usleep(i32 100000)
%15 = add nsw i32 %2, %1
%16 = call i32 @setFreq(i32 %0, i8 signext 66, i32 %15)
br label %17
17: ; preds = %3, %11
ret void
}