#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CheckResult(int /*<<< orphan*/ *);
int /*<<< orphan*/ EndAtomic(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int M_PI;
int /*<<< orphan*/ SetAlpha(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                            int);
int /*<<< orphan*/ SetPosition(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                               int, int);
int /*<<< orphan*/ SetVisibility(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                 int, int);
int /*<<< orphan*/ StartAtomic(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int abs(int);
double cos(float);
int /*<<< orphan*/ printf(char *);
double sin(float);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ usleep(int);
void BasicTest(FILE *p_cmd, FILE *p_res, int i_overlay) {
  printf("Activating overlay...");
  SetVisibility(p_cmd, p_res, i_overlay, 1);
  printf(" done\n");
  printf("Sweeping alpha...");
  for (int i_alpha = 0xFF; i_alpha >= -0xFF; i_alpha -= 8) {
    SetAlpha(p_cmd, p_res, i_overlay, abs(i_alpha));
    usleep(20000);
  }
  SetAlpha(p_cmd, p_res, i_overlay, 255);
  printf(" done\n");
  printf("Circle motion...");
  for (float f_theta = 0; f_theta <= 2 * M_PI; f_theta += M_PI / 64.0) {
    SetPosition(p_cmd, p_res, i_overlay, (int)(-cos(f_theta) * 100.0 + 100.0),
                (int)(-sin(f_theta) * 100.0 + 100.0));
    usleep(20000);
  }
  SetPosition(p_cmd, p_res, i_overlay, 0, 100);
  printf(" done\n");
  printf("Atomic motion...");
  StartAtomic(p_cmd, p_res);
  SetPosition(p_cmd, NULL, i_overlay, 200, 50);
  sleep(1);
  SetPosition(p_cmd, NULL, i_overlay, 0, 0);
  EndAtomic(p_cmd, p_res);
  CheckResult(p_res);
  CheckResult(p_res);
  printf(" done\n");
  sleep(5);
}


x86 assembly (clang, -O0):
<BasicTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xe36(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x1,%ecx
call   10b0 <SetVisibility@plt>
lea    0xe2b(%rip),%rdi
call   1070 <printf@plt>
lea    0xe26(%rip),%rdi
call   1070 <printf@plt>
movl   $0xff,-0x18(%rbp)
cmpl   $0xffffff01,-0x18(%rbp)
jl     1268 <BasicTest+0xa8>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <abs@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
call   1030 <SetAlpha@plt>
mov    $0x4e20,%edi
call   10e0 <usleep@plt>
mov    -0x18(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    1213 <BasicTest+0x53>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0xff,%ecx
call   1030 <SetAlpha@plt>
lea    0xda2(%rip),%rdi
call   1070 <printf@plt>
lea    0xdaf(%rip),%rdi
call   1070 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
ucomiss %xmm1,%xmm0
jb     138e <BasicTest+0x1ce>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
movss  -0x1c(%rbp),%xmm0
call   10c0 <cos@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd06(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1090 <sin@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%ecx
movq   %xmm0,%rax
movabs $0x8000000000000000,%r8
xor    %r8,%rax
movq   %rax,%xmm0
movsd  0xcc0(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
call   1050 <SetPosition@plt>
mov    $0x4e20,%edi
call   10e0 <usleep@plt>
mov    0x2c85(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xc99(%rip),%xmm0
divsd  %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    129d <BasicTest+0xdd>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
mov    $0x64,%r8d
call   1050 <SetPosition@plt>
lea    0xc79(%rip),%rdi
call   1070 <printf@plt>
lea    0xc97(%rip),%rdi
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <StartAtomic@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
mov    $0xc8,%ecx
mov    $0x32,%r8d
call   1050 <SetPosition@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1050 <SetPosition@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <EndAtomic@plt>
mov    -0x10(%rbp),%rdi
call   1080 <CheckResult@plt>
mov    -0x10(%rbp),%rdi
call   1080 <CheckResult@plt>
lea    0xbfa(%rip),%rdi
call   1070 <printf@plt>
mov    $0x5,%edi
call   10d0 <sleep@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicTest>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe34(%rip),%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    $0x1,%ecx
call   10b0 <SetVisibility@plt>
lea    0xe5f(%rip),%rdi
call   1060 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1070 <printf@plt>
mov    $0x107,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xfffffff8,%ebp
mov    %ebp,%ecx
neg    %ecx
cmovs  %ebp,%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <SetAlpha@plt>
mov    $0x4e20,%edi
call   10e0 <usleep@plt>
cmp    $0xffffff08,%ebp
jg     1220 <BasicTest+0x60>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    $0xff,%ecx
call   1030 <SetAlpha@plt>
lea    0xdf6(%rip),%rdi
call   1060 <puts@plt>
lea    0xdc8(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d6c(%rip),%r15
cmpl   $0x0,(%r15)
js     1322 <BasicTest+0x162>
xorpd  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
call   10c0 <cos@plt>
movsd  0xd5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
movss  0xc(%rsp),%xmm0
call   1090 <sin@plt>
movsd  0xd3e(%rip),%xmm1
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1050 <SetPosition@plt>
mov    $0x4e20,%edi
call   10e0 <usleep@plt>
mov    (%r15),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd0d(%rip),%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm1
add    %eax,%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
ucomiss %xmm0,%xmm2
jae    1290 <BasicTest+0xd0>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    $0x64,%r8d
call   1050 <SetPosition@plt>
lea    0xd1b(%rip),%r15
mov    %r15,%rdi
call   1060 <puts@plt>
lea    0xcfb(%rip),%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <StartAtomic@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12d,%edx
mov    $0xc8,%ecx
mov    $0x32,%r8d
call   1050 <SetPosition@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <SetPosition@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <EndAtomic@plt>
mov    %r14,%rdi
call   1080 <CheckResult@plt>
mov    %r14,%rdi
call   1080 <CheckResult@plt>
mov    %r15,%rdi
call   1060 <puts@plt>
mov    $0x5,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <sleep@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Activating overlay...\00"
@.str.1 = [7 x i8] c" done\0A\00"
@.str.2 = [18 x i8] c"Sweeping alpha...\00"
@.str.3 = [17 x i8] c"Circle motion...\00"
@M_PI = global i32 0
@.str.4 = [17 x i8] c"Atomic motion...\00"
define void @BasicTest(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = load i32*, i32** %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = call i32 @SetVisibility(i32* %10, i32* %11, i32 %12, i32 1)
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 255, i32* %7
br label %16
16: ; preds = %27, %3
%17 = load i32, i32* %7
%18 = icmp sge i32 %17, -255
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load i32*, i32** %4
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 @abs(i32 %23)
%25 = call i32 @SetAlpha(i32* %20, i32* %21, i32 %22, i32 %24)
%26 = call i32 @usleep(i32 20000)
br label %27
27: ; preds = %19
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 8
store i32 %29, i32* %7
br label %16
30: ; preds = %16
%31 = load i32*, i32** %4
%32 = load i32*, i32** %5
%33 = load i32, i32* %6
%34 = call i32 @SetAlpha(i32* %31, i32* %32, i32 %33, i32 255)
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store float 0.000000e+00, float* %8
br label %37
37: ; preds = %59, %30
%38 = load float, float* %8
%39 = load i32, i32* @M_PI
%40 = mul nsw i32 2, %39
%41 = sitofp i32 %40 to float
%42 = fcmp ole float %38, %41
br i1 %42, label %43, label %67
43: ; preds = %37
%44 = load i32*, i32** %4
%45 = load i32*, i32** %5
%46 = load i32, i32* %6
%47 = load float, float* %8
%48 = call double @cos(float %47)
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double %49, double 1.000000e+02, double 1.000000e+02)
%51 = fptosi double %50 to i32
%52 = load float, float* %8
%53 = call double @sin(float %52)
%54 = fneg double %53
%55 = call double @llvm.fmuladd.f64(double %54, double 1.000000e+02, double 1.000000e+02)
%56 = fptosi double %55 to i32
%57 = call i32 @SetPosition(i32* %44, i32* %45, i32 %46, i32 %51, i32 %56)
%58 = call i32 @usleep(i32 20000)
br label %59
59: ; preds = %43
%60 = load i32, i32* @M_PI
%61 = sitofp i32 %60 to double
%62 = fdiv double %61, 6.400000e+01
%63 = load float, float* %8
%64 = fpext float %63 to double
%65 = fadd double %64, %62
%66 = fptrunc double %65 to float
store float %66, float* %8
br label %37
67: ; preds = %37
%68 = load i32*, i32** %4
%69 = load i32*, i32** %5
%70 = load i32, i32* %6
%71 = call i32 @SetPosition(i32* %68, i32* %69, i32 %70, i32 0, i32 100)
%72 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%73 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%74 = load i32*, i32** %4
%75 = load i32*, i32** %5
%76 = call i32 @StartAtomic(i32* %74, i32* %75)
%77 = load i32*, i32** %4
%78 = load i32, i32* %6
%79 = call i32 @SetPosition(i32* %77, i32* null, i32 %78, i32 200, i32 50)
%80 = call i32 @sleep(i32 1)
%81 = load i32*, i32** %4
%82 = load i32, i32* %6
%83 = call i32 @SetPosition(i32* %81, i32* null, i32 %82, i32 0, i32 0)
%84 = load i32*, i32** %4
%85 = load i32*, i32** %5
%86 = call i32 @EndAtomic(i32* %84, i32* %85)
%87 = load i32*, i32** %5
%88 = call i32 @CheckResult(i32* %87)
%89 = load i32*, i32** %5
%90 = call i32 @CheckResult(i32* %89)
%91 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%92 = call i32 @sleep(i32 5)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Activating overlay...\00"
@.str.2 = [18 x i8] c"Sweeping alpha...\00"
@.str.3 = [17 x i8] c"Circle motion...\00"
@M_PI = global i32 0
@.str.4 = [17 x i8] c"Atomic motion...\00"
@str.7 = [6 x i8] c" done\00"
define void @BasicTest(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @SetVisibility(i32* %0, i32* %1, i32 %2, i32 1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %14
8: ; preds = %14
%9 = tail call i32 @SetAlpha(i32* %0, i32* %1, i32 %2, i32 255)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @M_PI
%13 = icmp slt i32 %12, 0
br i1 %13, label %21, label %34
14: ; preds = %3, %14
%15 = phi i32 [ 255, %3 ], [ %19, %14 ]
%16 = tail call i32 @llvm.abs.i32(i32 %15, i1 true)
%17 = tail call i32 @SetAlpha(i32* %0, i32* %1, i32 %2, i32 %16)
%18 = tail call i32 @usleep(i32 20000)
%19 = add nsw i32 %15, -8
%20 = icmp sgt i32 %15, -248
br i1 %20, label %14, label %8
21: ; preds = %34, %8
%22 = tail call i32 @SetPosition(i32* %0, i32* %1, i32 %2, i32 0, i32 100)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%25 = tail call i32 @StartAtomic(i32* %0, i32* %1)
%26 = tail call i32 @SetPosition(i32* %0, i32* null, i32 %2, i32 200, i32 50)
%27 = tail call i32 @sleep(i32 1)
%28 = tail call i32 @SetPosition(i32* %0, i32* null, i32 %2, i32 0, i32 0)
%29 = tail call i32 @EndAtomic(i32* %0, i32* %1)
%30 = tail call i32 @CheckResult(i32* %1)
%31 = tail call i32 @CheckResult(i32* %1)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%33 = tail call i32 @sleep(i32 5)
ret void
34: ; preds = %8, %34
%35 = phi float [ %51, %34 ], [ 0.000000e+00, %8 ]
%36 = tail call double @cos(float %35)
%37 = fneg double %36
%38 = tail call double @llvm.fmuladd.f64(double %37, double 1.000000e+02, double 1.000000e+02)
%39 = fptosi double %38 to i32
%40 = tail call double @sin(float %35)
%41 = fneg double %40
%42 = tail call double @llvm.fmuladd.f64(double %41, double 1.000000e+02, double 1.000000e+02)
%43 = fptosi double %42 to i32
%44 = tail call i32 @SetPosition(i32* %0, i32* %1, i32 %2, i32 %39, i32 %43)
%45 = tail call i32 @usleep(i32 20000)
%46 = load i32, i32* @M_PI
%47 = sitofp i32 %46 to double
%48 = fmul double %47, 1.562500e-02
%49 = fpext float %35 to double
%50 = fadd double %48, %49
%51 = fptrunc double %50 to float
%52 = shl nsw i32 %46, 1
%53 = sitofp i32 %52 to float
%54 = fcmp ugt float %51, %53
br i1 %54, label %21, label %34
}