#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*/ InitPWM(int);
int /*<<< orphan*/ LEDOff(int);
int /*<<< orphan*/ LEDOn(int);
int /*<<< orphan*/ SetPWMDuty(int, int);
int /*<<< orphan*/ SetPWMOnOff(int, int);
int /*<<< orphan*/ SetPWMPeriod(int, int);
int /*<<< orphan*/ SetPinValue(int, int);
int /*<<< orphan*/ SettingCape();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
int main() {
  int i = 0, j = 0;
  int cnt = 0;
  printf("Start\n");
  SettingCape();
  LEDOn(23);
  LEDOn(47);
  printf("pwm0_On\n");
  InitPWM(0);
  SetPWMPeriod(0, 20000000);
  SetPWMDuty(0, 11.0);
  SetPWMOnOff(0, 1);
  printf("pwm1_On\n");
  InitPWM(1);
  SetPWMPeriod(1, 20000000);
  SetPWMDuty(1, 4);
  SetPWMOnOff(1, 1);
  printf("Select 0 or 1\n");
  usleep(1000000);
  for (i = 0; i < 5; i++) {
    SetPinValue(23, 0);
    printf("Select 0\n");
    usleep(1000000);
    SetPinValue(23, 1);
    printf("Select 1\n");
    usleep(1000000);
  }
  printf("End\n");
  LEDOff(46);
  LEDOff(23);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe35(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <SettingCape@plt>
mov    $0x17,%edi
call   10b0 <LEDOn@plt>
mov    $0x2f,%edi
call   10b0 <LEDOn@plt>
lea    0xe15(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1070 <InitPWM@plt>
xor    %edi,%edi
mov    $0x1312d00,%esi
call   1090 <SetPWMPeriod@plt>
xor    %edi,%edi
mov    $0xb,%esi
call   1030 <SetPWMDuty@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <SetPWMOnOff@plt>
lea    0xde7(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1070 <InitPWM@plt>
mov    $0x1,%edi
mov    $0x1312d00,%esi
call   1090 <SetPWMPeriod@plt>
mov    $0x1,%edi
mov    $0x4,%esi
call   1030 <SetPWMDuty@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   10a0 <SetPWMOnOff@plt>
lea    0xdb0(%rip),%rdi
call   1060 <printf@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    12de <main+0x13e>
mov    $0x17,%edi
xor    %esi,%esi
call   1040 <SetPinValue@plt>
lea    0xd8c(%rip),%rdi
call   1060 <printf@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1040 <SetPinValue@plt>
lea    0xd71(%rip),%rdi
call   1060 <printf@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    127f <main+0xdf>
lea    0xd57(%rip),%rdi
call   1060 <printf@plt>
mov    $0x2e,%edi
call   1050 <LEDOff@plt>
mov    $0x17,%edi
call   1050 <LEDOff@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <SettingCape@plt>
mov    $0x17,%edi
call   10b0 <LEDOn@plt>
mov    $0x2f,%edi
call   10b0 <LEDOn@plt>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <InitPWM@plt>
xor    %edi,%edi
mov    $0x1312d00,%esi
call   1090 <SetPWMPeriod@plt>
xor    %edi,%edi
mov    $0xb,%esi
call   1040 <SetPWMDuty@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <SetPWMOnOff@plt>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <InitPWM@plt>
mov    $0x1,%edi
mov    $0x1312d00,%esi
call   1090 <SetPWMPeriod@plt>
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <SetPWMDuty@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   10a0 <SetPWMOnOff@plt>
lea    0xdca(%rip),%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
lea    0xdba(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
lea    0xd9b(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
call   10c0 <usleep@plt>
lea    0xc79(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2e,%edi
call   1060 <LEDOff@plt>
mov    $0x17,%edi
call   1060 <LEDOff@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Start\0A\00"
@.str.1 = [9 x i8] c"pwm0_On\0A\00"
@.str.2 = [9 x i8] c"pwm1_On\0A\00"
@.str.3 = [15 x i8] c"Select 0 or 1\0A\00"
@.str.4 = [10 x i8] c"Select 0\0A\00"
@.str.5 = [10 x i8] c"Select 1\0A\00"
@.str.6 = [5 x i8] c"End\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @SettingCape()
%7 = call i32 @LEDOn(i32 23)
%8 = call i32 @LEDOn(i32 47)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @InitPWM(i32 0)
%11 = call i32 @SetPWMPeriod(i32 0, i32 20000000)
%12 = call i32 @SetPWMDuty(i32 0, i32 11)
%13 = call i32 @SetPWMOnOff(i32 0, i32 1)
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @InitPWM(i32 1)
%16 = call i32 @SetPWMPeriod(i32 1, i32 20000000)
%17 = call i32 @SetPWMDuty(i32 1, i32 4)
%18 = call i32 @SetPWMOnOff(i32 1, i32 1)
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @usleep(i32 1000000)
store i32 0, i32* %2
br label %21
21: ; preds = %31, %0
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = call i32 @SetPinValue(i32 23, i32 0)
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @usleep(i32 1000000)
%28 = call i32 @SetPinValue(i32 23, i32 1)
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @usleep(i32 1000000)
br label %31
31: ; preds = %24
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %21
34: ; preds = %21
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%36 = call i32 @LEDOff(i32 46)
%37 = call i32 @LEDOff(i32 23)
ret i32 0
}

LLVM IR (-O2):
@str = [6 x i8] c"Start\00"
@str.7 = [8 x i8] c"pwm0_On\00"
@str.8 = [8 x i8] c"pwm1_On\00"
@str.9 = [14 x i8] c"Select 0 or 1\00"
@str.10 = [4 x i8] c"End\00"
@str.11 = [9 x i8] c"Select 0\00"
@str.12 = [9 x i8] c"Select 1\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @SettingCape()
%3 = tail call i32 @LEDOn(i32 23)
%4 = tail call i32 @LEDOn(i32 47)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @InitPWM(i32 0)
%7 = tail call i32 @SetPWMPeriod(i32 0, i32 20000000)
%8 = tail call i32 @SetPWMDuty(i32 0, i32 11)
%9 = tail call i32 @SetPWMOnOff(i32 0, i32 1)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0))
%11 = tail call i32 @InitPWM(i32 1)
%12 = tail call i32 @SetPWMPeriod(i32 1, i32 20000000)
%13 = tail call i32 @SetPWMDuty(i32 1, i32 4)
%14 = tail call i32 @SetPWMOnOff(i32 1, i32 1)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
%16 = tail call i32 @usleep(i32 1000000)
%17 = tail call i32 @SetPinValue(i32 23, i32 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%19 = tail call i32 @usleep(i32 1000000)
%20 = tail call i32 @SetPinValue(i32 23, i32 1)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%22 = tail call i32 @usleep(i32 1000000)
%23 = tail call i32 @SetPinValue(i32 23, i32 0)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%25 = tail call i32 @usleep(i32 1000000)
%26 = tail call i32 @SetPinValue(i32 23, i32 1)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%28 = tail call i32 @usleep(i32 1000000)
%29 = tail call i32 @SetPinValue(i32 23, i32 0)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%31 = tail call i32 @usleep(i32 1000000)
%32 = tail call i32 @SetPinValue(i32 23, i32 1)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%34 = tail call i32 @usleep(i32 1000000)
%35 = tail call i32 @SetPinValue(i32 23, i32 0)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%37 = tail call i32 @usleep(i32 1000000)
%38 = tail call i32 @SetPinValue(i32 23, i32 1)
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%40 = tail call i32 @usleep(i32 1000000)
%41 = tail call i32 @SetPinValue(i32 23, i32 0)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%43 = tail call i32 @usleep(i32 1000000)
%44 = tail call i32 @SetPinValue(i32 23, i32 1)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%46 = tail call i32 @usleep(i32 1000000)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
%48 = tail call i32 @LEDOff(i32 46)
%49 = tail call i32 @LEDOff(i32 23)
ret i32 0
}