#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, int);
int /*<<< orphan*/ clear_channel_gpio(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) {
  if (argc == 2 && !strcmp(argv[1], "--pcm"))
    setup(10, 1);
  else
    setup(10, 0);
  int demo_timeout = 10 * 1000000;
  int gpio = 17;
  int channel = 0;
  int subcycle_time_us = 20000;
  init_channel(channel, subcycle_time_us);
  print_channel(channel);
  add_channel_pulse(channel, gpio, 0, 50);
  add_channel_pulse(channel, gpio, 100, 50);
  add_channel_pulse(channel, gpio, 200, 50);
  add_channel_pulse(channel, gpio, 300, 50);
  usleep(demo_timeout);
  clear_channel_gpio(0, 17);
  add_channel_pulse(channel, gpio, 0, 50);
  usleep(demo_timeout);
  shutdown();
  exit(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)
cmpl   $0x2,-0x8(%rbp)
jne    11e1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe41(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e1 <main+0x51>
mov    $0xa,%edi
mov    $0x1,%esi
call   10a0 <setup@plt>
jmp    11ed <main+0x5d>
mov    $0xa,%edi
xor    %esi,%esi
call   10a0 <setup@plt>
movl   $0x989680,-0x14(%rbp)
movl   $0x11,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x4e20,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1070 <init_channel@plt>
mov    -0x1c(%rbp),%edi
call   1080 <print_channel@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x64,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0xc8,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x12c,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    -0x14(%rbp),%edi
call   10b0 <usleep@plt>
xor    %edi,%edi
mov    $0x11,%esi
call   1050 <clear_channel_gpio@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    -0x14(%rbp),%edi
call   10b0 <usleep@plt>
mov    $0x0,%al
call   1040 <shutdown@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    11af <main+0x1f>
mov    0x8(%rsi),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <strcmp@plt>
mov    $0x1,%esi
test   %eax,%eax
je     11b1 <main+0x21>
xor    %esi,%esi
mov    $0xa,%edi
call   10a0 <setup@plt>
xor    %edi,%edi
mov    $0x4e20,%esi
call   1070 <init_channel@plt>
xor    %edi,%edi
call   1080 <print_channel@plt>
xor    %edi,%edi
mov    $0x11,%esi
xor    %edx,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
xor    %edi,%edi
mov    $0x11,%esi
mov    $0x64,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
xor    %edi,%edi
mov    $0x11,%esi
mov    $0xc8,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
xor    %edi,%edi
mov    $0x11,%esi
mov    $0x12c,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x989680,%edi
call   10b0 <usleep@plt>
xor    %edi,%edi
mov    $0x11,%esi
call   1050 <clear_channel_gpio@plt>
xor    %edi,%edi
mov    $0x11,%esi
xor    %edx,%edx
mov    $0x32,%ecx
call   1030 <add_channel_pulse@plt>
mov    $0x989680,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1040 <shutdown@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"--pcm\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 i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = call i32 @setup(i32 10, i32 1)
br label %22
20: ; preds = %12, %2
%21 = call i32 @setup(i32 10, i32 0)
br label %22
22: ; preds = %20, %18
store i32 10000000, i32* %6
store i32 17, i32* %7
store i32 0, i32* %8
store i32 20000, i32* %9
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @init_channel(i32 %23, i32 %24)
%26 = load i32, i32* %8
%27 = call i32 @print_channel(i32 %26)
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = call i32 @add_channel_pulse(i32 %28, i32 %29, i32 0, i32 50)
%31 = load i32, i32* %8
%32 = load i32, i32* %7
%33 = call i32 @add_channel_pulse(i32 %31, i32 %32, i32 100, i32 50)
%34 = load i32, i32* %8
%35 = load i32, i32* %7
%36 = call i32 @add_channel_pulse(i32 %34, i32 %35, i32 200, i32 50)
%37 = load i32, i32* %8
%38 = load i32, i32* %7
%39 = call i32 @add_channel_pulse(i32 %37, i32 %38, i32 300, i32 50)
%40 = load i32, i32* %6
%41 = call i32 @usleep(i32 %40)
%42 = call i32 @clear_channel_gpio(i32 0, i32 17)
%43 = load i32, i32* %8
%44 = load i32, i32* %7
%45 = call i32 @add_channel_pulse(i32 %43, i32 %44, i32 0, i32 50)
%46 = load i32, i32* %6
%47 = call i32 @usleep(i32 %46)
%48 = call i32 (...) @shutdown()
%49 = call i32 @exit(i32 0)
unreachable
}

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 10, i32 %11)
%13 = tail call i32 @init_channel(i32 0, i32 20000)
%14 = tail call i32 @print_channel(i32 0)
%15 = tail call i32 @add_channel_pulse(i32 0, i32 17, i32 0, i32 50)
%16 = tail call i32 @add_channel_pulse(i32 0, i32 17, i32 100, i32 50)
%17 = tail call i32 @add_channel_pulse(i32 0, i32 17, i32 200, i32 50)
%18 = tail call i32 @add_channel_pulse(i32 0, i32 17, i32 300, i32 50)
%19 = tail call i32 @usleep(i32 10000000)
%20 = tail call i32 @clear_channel_gpio(i32 0, i32 17)
%21 = tail call i32 @add_channel_pulse(i32 0, i32 17, i32 0, i32 50)
%22 = tail call i32 @usleep(i32 10000000)
%23 = tail call i32 (...) @shutdown()
%24 = tail call i32 @exit(i32 0)
unreachable
}