#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*/ CloseGPin(int);
int /*<<< orphan*/ InitPWM(int);
int /*<<< orphan*/ InitPin(int);
int /*<<< orphan*/ SetPWMDuty(int, double);
int /*<<< orphan*/ SetPWMOnOff(int, int);
int /*<<< orphan*/ SetPWMPeriod(int, int);
int /*<<< orphan*/ SetPinDirt(int, char *);
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();
  InitPin(23);
  SetPinDirt(23, "out");
  SetPinValue(23, 1);
  printf("pwm0\n");
  InitPWM(1);
  SetPWMPeriod(1, 20000000);
  SetPWMDuty(1, 10);
  SetPWMOnOff(1, 1);
  for (cnt = 0; cnt < 8; cnt++) {
    SetPWMDuty(1, 3.5 + (double)cnt);
    usleep(500000);
  }
  printf("End\n");
  usleep(1000000);
  SetPinValue(23, 0);
  CloseGPin(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   1090 <SettingCape@plt>
mov    $0x17,%edi
call   1030 <InitPin@plt>
mov    $0x17,%edi
lea    0xe1a(%rip),%rsi
call   1080 <SetPinDirt@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1050 <SetPinValue@plt>
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1070 <InitPWM@plt>
mov    $0x1,%edi
mov    $0x1312d00,%esi
call   10b0 <SetPWMPeriod@plt>
mov    $0x1,%edi
movsd  0xdbd(%rip),%xmm0
call   1040 <SetPWMDuty@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   10c0 <SetPWMOnOff@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1298 <main+0xe8>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xd96(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    $0x1,%edi
call   1040 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    125b <main+0xab>
lea    0xd82(%rip),%rdi
call   1060 <printf@plt>
mov    $0xf4240,%edi
call   10d0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1050 <SetPinValue@plt>
mov    $0x17,%edi
call   10a0 <CloseGPin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <SettingCape@plt>
mov    $0x17,%edi
call   1030 <InitPin@plt>
lea    0xe73(%rip),%rsi
mov    $0x17,%edi
call   1080 <SetPinDirt@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1060 <SetPinValue@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <InitPWM@plt>
mov    $0x1,%edi
mov    $0x1312d00,%esi
call   10b0 <SetPWMPeriod@plt>
movsd  0xde5(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   10c0 <SetPWMOnOff@plt>
movsd  0xdcc(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xdb8(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xda4(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xd90(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xd7c(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xd68(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xd54(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
movsd  0xd40(%rip),%xmm0
mov    $0x1,%edi
call   1050 <SetPWMDuty@plt>
mov    $0x7a120,%edi
call   10d0 <usleep@plt>
lea    0xd3c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xf4240,%edi
call   10d0 <usleep@plt>
mov    $0x17,%edi
xor    %esi,%esi
call   1060 <SetPinValue@plt>
mov    $0x17,%edi
call   10a0 <CloseGPin@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Start\0A\00"
@.str.1 = [4 x i8] c"out\00"
@.str.2 = [6 x i8] c"pwm0\0A\00"
@.str.3 = [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 @InitPin(i32 23)
%8 = call i32 @SetPinDirt(i32 23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @SetPinValue(i32 23, i32 1)
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @InitPWM(i32 1)
%12 = call i32 @SetPWMPeriod(i32 1, i32 20000000)
%13 = call i32 @SetPWMDuty(i32 1, double 1.000000e+01)
%14 = call i32 @SetPWMOnOff(i32 1, i32 1)
store i32 0, i32* %4
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 8
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %4
%20 = sitofp i32 %19 to double
%21 = fadd double 3.500000e+00, %20
%22 = call i32 @SetPWMDuty(i32 1, double %21)
%23 = call i32 @usleep(i32 500000)
br label %24
24: ; preds = %18
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %15
27: ; preds = %15
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @usleep(i32 1000000)
%30 = call i32 @SetPinValue(i32 23, i32 0)
%31 = call i32 @CloseGPin(i32 23)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"out\00"
@str = [6 x i8] c"Start\00"
@str.4 = [5 x i8] c"pwm0\00"
@str.5 = [4 x i8] c"End\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 @InitPin(i32 23)
%4 = tail call i32 @SetPinDirt(i32 23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @SetPinValue(i32 23, i32 1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
%7 = tail call i32 @InitPWM(i32 1)
%8 = tail call i32 @SetPWMPeriod(i32 1, i32 20000000)
%9 = tail call i32 @SetPWMDuty(i32 1, double 1.000000e+01)
%10 = tail call i32 @SetPWMOnOff(i32 1, i32 1)
%11 = tail call i32 @SetPWMDuty(i32 1, double 3.500000e+00)
%12 = tail call i32 @usleep(i32 500000)
%13 = tail call i32 @SetPWMDuty(i32 1, double 4.500000e+00)
%14 = tail call i32 @usleep(i32 500000)
%15 = tail call i32 @SetPWMDuty(i32 1, double 5.500000e+00)
%16 = tail call i32 @usleep(i32 500000)
%17 = tail call i32 @SetPWMDuty(i32 1, double 6.500000e+00)
%18 = tail call i32 @usleep(i32 500000)
%19 = tail call i32 @SetPWMDuty(i32 1, double 7.500000e+00)
%20 = tail call i32 @usleep(i32 500000)
%21 = tail call i32 @SetPWMDuty(i32 1, double 8.500000e+00)
%22 = tail call i32 @usleep(i32 500000)
%23 = tail call i32 @SetPWMDuty(i32 1, double 9.500000e+00)
%24 = tail call i32 @usleep(i32 500000)
%25 = tail call i32 @SetPWMDuty(i32 1, double 1.050000e+01)
%26 = tail call i32 @usleep(i32 500000)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.5, i64 0, i64 0))
%28 = tail call i32 @usleep(i32 1000000)
%29 = tail call i32 @SetPinValue(i32 23, i32 0)
%30 = tail call i32 @CloseGPin(i32 23)
ret i32 0
}