#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*/ add_channel_pulse(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ init_channel(int, int);
int /*<<< orphan*/ print_channel(int);
int /*<<< orphan*/ setup(int, int);
int /*<<< orphan*/ shutdown();
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  int i = 0;
  if (argc == 2 && !strcmp(argv[1], "--pcm"))
    setup(1, 1);
  else
    setup(1, 0);
  int demo_timeout = 10 * 1000000;
  int gpio[] = {25, 23, 24};
  int esc[] = {24, 17, 4, 27, 25, 22, 23};
  int channel = 0;
  int subcycle_time_us = 20000;
  int j;
  init_channel(channel, subcycle_time_us);
  print_channel(channel);
  while (1) {
    add_channel_pulse(channel, 18, 0, 1000);
    usleep(5000000);
    add_channel_pulse(channel, 18, 0, 3300);
    usleep(5000000);
    add_channel_pulse(channel, 18, 0, 1000);
  }
  add_channel_pulse(channel, esc[i], 0, 3000);
  usleep(5000000);
  shutdown();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11b5 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b5 <main+0x55>
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <setup@plt>
jmp    11c1 <main+0x61>
mov    $0x1,%edi
xor    %esi,%esi
call   1070 <setup@plt>
movl   $0x989680,-0x18(%rbp)
mov    0xe41(%rip),%rax
mov    %rax,-0x24(%rbp)
mov    0xe3f(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    0xe3d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe3a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe37(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe35(%rip),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x4e20,-0x48(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1050 <init_channel@plt>
mov    -0x44(%rbp),%edi
call   1060 <print_channel@plt>
mov    -0x44(%rbp),%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0x3e8,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x4c4b40,%edi
call   1080 <usleep@plt>
mov    -0x44(%rbp),%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0xce4,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x4c4b40,%edi
call   1080 <usleep@plt>
mov    -0x44(%rbp),%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0x3e8,%ecx
call   1030 <add_channel_pulse@plt>
jmp    1227 <main+0xc7>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    117a <main+0x1a>
mov    0x8(%rsi),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     117e <main+0x1e>
xor    %esi,%esi
jmp    1183 <main+0x23>
mov    $0x1,%esi
mov    $0x1,%edi
call   1070 <setup@plt>
xor    %edi,%edi
mov    $0x4e20,%esi
call   1050 <init_channel@plt>
xor    %edi,%edi
call   1060 <print_channel@plt>
xor    %edi,%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0x3e8,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x4c4b40,%edi
call   1080 <usleep@plt>
xor    %edi,%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0xce4,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x4c4b40,%edi
call   1080 <usleep@plt>
xor    %edi,%edi
mov    $0x12,%esi
xor    %edx,%edx
mov    $0x3e8,%ecx
call   1030 <add_channel_pulse@plt>
jmp    11a0 <main+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"--pcm\00"
@__const.main.gpio = [3 x i32] [i32 25, i32 23, i32 24]
@__const.main.esc = [7 x i32] [i32 24, i32 17, i32 4, i32 27, i32 25, i32 22, i32 23]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [3 x i32]
%9 = alloca [7 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = call i32 @setup(i32 1, i32 1)
br label %25
23: ; preds = %15, %2
%24 = call i32 @setup(i32 1, i32 0)
br label %25
25: ; preds = %23, %21
store i32 10000000, i32* %7
%26 = bitcast [3 x i32]* %8 to i8*
%27 = bitcast [7 x i32]* %9 to i8*
store i32 0, i32* %10
store i32 20000, i32* %11
%28 = load i32, i32* %10
%29 = load i32, i32* %11
%30 = call i32 @init_channel(i32 %28, i32 %29)
%31 = load i32, i32* %10
%32 = call i32 @print_channel(i32 %31)
br label %33
33: ; preds = %25, %33
%34 = load i32, i32* %10
%35 = call i32 @add_channel_pulse(i32 %34, i32 18, i32 0, i32 1000)
%36 = call i32 @usleep(i32 5000000)
%37 = load i32, i32* %10
%38 = call i32 @add_channel_pulse(i32 %37, i32 18, i32 0, i32 3300)
%39 = call i32 @usleep(i32 5000000)
%40 = load i32, i32* %10
%41 = call i32 @add_channel_pulse(i32 %40, i32 18, i32 0, i32 1000)
br label %33
}

LLVM IR (-O2):
@.str = [6 x i8] c"--pcm\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %4, %2
br label %10
10: ; preds = %4, %9
%11 = phi i32 [ 0, %9 ], [ 1, %4 ]
%12 = tail call i32 @setup(i32 1, i32 %11)
%13 = tail call i32 @init_channel(i32 0, i32 20000)
%14 = tail call i32 @print_channel(i32 0)
br label %15
15: ; preds = %15, %10
%16 = tail call i32 @add_channel_pulse(i32 0, i32 18, i32 0, i32 1000)
%17 = tail call i32 @usleep(i32 5000000)
%18 = tail call i32 @add_channel_pulse(i32 0, i32 18, i32 0, i32 3300)
%19 = tail call i32 @usleep(i32 5000000)
%20 = tail call i32 @add_channel_pulse(i32 0, i32 18, i32 0, i32 1000)
br label %15
}