#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*/ dds_frequency(int, unsigned char);
int /*<<< orphan*/ gpio_direction(char *, char *);
int /*<<< orphan*/ gpio_pulse(char *);
int /*<<< orphan*/ gpio_value(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void *strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned char phase = 0;
  int frequency = 0;
  gpio_direction("11", "out");
  gpio_direction("25", "out");
  gpio_direction("9", "out");
  gpio_direction("8", "out");
  gpio_value("11", "0");
  gpio_value("25", "0");
  gpio_value("9", "0");
  gpio_value("8", "0");
  gpio_pulse("8");
  gpio_pulse("11");
  gpio_pulse("25");
  if (argc < 2) {
    printf("%s", "\n  \033[1mDDS AD9850 Controller by blog.everpi.net\n\n"
                 "\tUsage:  [option] [frequency in HZ] [phase]\n"
                 "\t         -o\tchip shutdown\n\n"
                 "\tPhase is optional, 31 Max.\033[0m\n\n");
    return 0;
  }
  if (argv[1][1] == 'o') {
    dds_frequency(0, 0x4);
    return 0;
  }
  if (argc > 3 && phase <= 31) {
    phase = strtol(argv[2], NULL, 10);
  }
  frequency = strtol(argv[1], NULL, 10);
  if (frequency <= 40000000) {
    dds_frequency(frequency, phase << 3);
  } else {
    printf("Frequency max:40000000\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe78(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1060 <gpio_direction@plt>
lea    0xe6c(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1060 <gpio_direction@plt>
lea    0xe5c(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   1060 <gpio_direction@plt>
lea    0xe4b(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <gpio_direction@plt>
lea    0xe2c(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1070 <gpio_value@plt>
lea    0xe20(%rip),%rdi
lea    0xe20(%rip),%rsi
call   1070 <gpio_value@plt>
lea    0xe10(%rip),%rdi
lea    0xe0d(%rip),%rsi
call   1070 <gpio_value@plt>
lea    0xdff(%rip),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <gpio_value@plt>
lea    0xdec(%rip),%rdi
call   1040 <gpio_pulse@plt>
lea    0xdd4(%rip),%rdi
call   1040 <gpio_pulse@plt>
lea    0xdcf(%rip),%rdi
call   1040 <gpio_pulse@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1268 <main+0x108>
lea    0xdc2(%rip),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1323 <main+0x1c3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    1295 <main+0x135>
xor    %edi,%edi
mov    $0x4,%esi
call   1080 <dds_frequency@plt>
movl   $0x0,-0x4(%rbp)
jmp    1323 <main+0x1c3>
cmpl   $0x3,-0x8(%rbp)
jle    12c5 <main+0x165>
movzbl -0x11(%rbp),%eax
cmp    $0x1f,%eax
jg     12c5 <main+0x165>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2625a00,-0x18(%rbp)
jg     1302 <main+0x1a2>
mov    -0x18(%rbp),%edi
movzbl -0x11(%rbp),%eax
shl    $0x3,%eax
movzbl %al,%esi
call   1080 <dds_frequency@plt>
jmp    131c <main+0x1bc>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1323 <main+0x1c3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %edi,%r15d
lea    0xe87(%rip),%r12
lea    0xe83(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <gpio_direction@plt>
lea    0xe75(%rip),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <gpio_direction@plt>
lea    0xe66(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <gpio_direction@plt>
lea    0xe56(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <gpio_direction@plt>
lea    0xe5b(%rip),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <gpio_value@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <gpio_value@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <gpio_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <gpio_value@plt>
mov    %r14,%rdi
call   1040 <gpio_pulse@plt>
mov    %r12,%rdi
call   1040 <gpio_pulse@plt>
mov    %r13,%rdi
call   1040 <gpio_pulse@plt>
cmp    $0x1,%r15d
jg     1222 <main+0xc2>
lea    0xe0c(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    1298 <main+0x138>
mov    (%rsp),%rbx
mov    0x8(%rbx),%rdi
cmpb   $0x6f,0x1(%rdi)
jne    1240 <main+0xe0>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x4,%esi
call   1080 <dds_frequency@plt>
jmp    1298 <main+0x138>
cmp    $0x4,%r15d
jb     1263 <main+0x103>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbp
shl    $0x3,%bpl
mov    0x8(%rbx),%rdi
jmp    1265 <main+0x105>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
cmp    $0x2625a00,%eax
jg     1287 <main+0x127>
movzbl %bpl,%esi
mov    %eax,%edi
call   1080 <dds_frequency@plt>
jmp    1298 <main+0x138>
lea    0xd80(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"11\00"
@.str.1 = [4 x i8] c"out\00"
@.str.2 = [3 x i8] c"25\00"
@.str.3 = [2 x i8] c"9\00"
@.str.4 = [2 x i8] c"8\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [155 x i8] c"\0A \1B[1mDDS AD9850 Controller by blog.everpi.net\0A\0A\09Usage: [option] [frequency in HZ] [phase]\0A\09 -o\09chip shutdown\0A\0A\09Phase is optional, 31 Max.\1B[0m\0A\0A\00"
@.str.8 = [24 x i8] c"Frequency max:40000000\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
store i32 0, i32* %7
%8 = call i32 @gpio_direction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @gpio_direction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gpio_direction(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @gpio_direction(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @gpio_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @gpio_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @gpio_value(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @gpio_value(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @gpio_pulse(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @gpio_pulse(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @gpio_pulse(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %64
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 111
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @dds_frequency(i32 0, i8 zeroext 4)
store i32 0, i32* %3
br label %64
33: ; preds = %23
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 3
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = icmp sle i32 %38, 31
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i8* @strtol(i8* %43, i32* null, i32 10)
%45 = ptrtoint i8* %44 to i8
store i8 %45, i8* %6
br label %46
46: ; preds = %40, %36, %33
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i8* @strtol(i8* %49, i32* null, i32 10)
%51 = ptrtoint i8* %50 to i32
store i32 %51, i32* %7
%52 = load i32, i32* %7
%53 = icmp sle i32 %52, 40000000
br i1 %53, label %54, label %61
54: ; preds = %46
%55 = load i32, i32* %7
%56 = load i8, i8* %6
%57 = zext i8 %56 to i32
%58 = shl i32 %57, 3
%59 = trunc i32 %58 to i8
%60 = call i32 @dds_frequency(i32 %55, i8 zeroext %59)
br label %63
61: ; preds = %46
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %64
63: ; preds = %54
store i32 0, i32* %3
br label %64
64: ; preds = %63, %61, %31, %21
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [3 x i8] c"11\00"
@.str.1 = [4 x i8] c"out\00"
@.str.2 = [3 x i8] c"25\00"
@.str.3 = [2 x i8] c"9\00"
@.str.4 = [2 x i8] c"8\00"
@.str.5 = [2 x i8] c"0\00"
@str = [23 x i8] c"Frequency max:40000000\00"
@str.9 = [154 x i8] c"\0A \1B[1mDDS AD9850 Controller by blog.everpi.net\0A\0A\09Usage: [option] [frequency in HZ] [phase]\0A\09 -o\09chip shutdown\0A\0A\09Phase is optional, 31 Max.\1B[0m\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @gpio_direction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @gpio_direction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @gpio_direction(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @gpio_direction(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @gpio_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i32 @gpio_value(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @gpio_value(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 @gpio_value(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @gpio_pulse(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @gpio_pulse(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @gpio_pulse(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp slt i32 %0, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([154 x i8], [154 x i8]* @str.9, i64 0, i64 0))
br label %46
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 111
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @dds_frequency(i32 0, i8 zeroext 4)
br label %46
25: ; preds = %17
%26 = icmp ugt i32 %0, 3
br i1 %26, label %27, label %35
27: ; preds = %25
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i8* @strtol(i8* nocapture %29, i32* null, i32 10)
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i8
%33 = shl i8 %32, 3
%34 = load i8*, i8** %18
br label %35
35: ; preds = %27, %25
%36 = phi i8* [ %34, %27 ], [ %19, %25 ]
%37 = phi i8 [ %33, %27 ], [ 0, %25 ]
%38 = tail call i8* @strtol(i8* nocapture %36, i32* null, i32 10)
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i32
%41 = icmp slt i32 %40, 40000001
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = tail call i32 @dds_frequency(i32 %40, i8 zeroext %37)
br label %46
44: ; preds = %35
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %46
46: ; preds = %42, %44, %23, %15
%47 = phi i32 [ 0, %15 ], [ 0, %23 ], [ 0, %42 ], [ -1, %44 ]
ret i32 %47
}