#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 */
double M_PI;
double sqrt(double);
void v_u_param_cylinder(int i, double u, double *pv) {
  double v = 0.0;
  double t = 0.0;
  if ((i == 1) || (i == 2)) {
    t = 1.0 - u * u;
    if (t > 1e-14)
      t = sqrt(t);
    else if (t < -1e-14)
      t = -sqrt(-t);
    else
      t = 0.0;
    if (i == 1)
      v = t;
    else if (i == 2)
      v = -t;
  } else if (i == 3) {
    v = 0.0;
  } else if (i == 4) {
    v = 1.0;
  } else if (i == 5) {
    v = -u;
  } else if (i == 6) {
    v = -u - M_PI;
  } else if (i == 7) {
    v = -u + M_PI;
  }
  *pv = v;
}


x86 assembly (clang, -O0):
<v_u_param_cylinder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1148 <v_u_param_cylinder+0x38>
cmpl   $0x2,-0x4(%rbp)
jne    1259 <v_u_param_cylinder+0x149>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe8b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a9 <v_u_param_cylinder+0x99>
movsd  -0x28(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    120b <v_u_param_cylinder+0xfb>
movsd  0xe5f(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11fe <v_u_param_cylinder+0xee>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1206 <v_u_param_cylinder+0xf6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    120b <v_u_param_cylinder+0xfb>
cmpl   $0x1,-0x4(%rbp)
jne    1224 <v_u_param_cylinder+0x114>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1254 <v_u_param_cylinder+0x144>
cmpl   $0x2,-0x4(%rbp)
jne    124f <v_u_param_cylinder+0x13f>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1254 <v_u_param_cylinder+0x144>
jmp    1346 <v_u_param_cylinder+0x236>
cmpl   $0x3,-0x4(%rbp)
jne    1270 <v_u_param_cylinder+0x160>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1341 <v_u_param_cylinder+0x231>
cmpl   $0x4,-0x4(%rbp)
jne    128c <v_u_param_cylinder+0x17c>
movsd  0xd7e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    133c <v_u_param_cylinder+0x22c>
cmpl   $0x5,-0x4(%rbp)
jne    12bc <v_u_param_cylinder+0x1ac>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1337 <v_u_param_cylinder+0x227>
cmpl   $0x6,-0x4(%rbp)
jne    12f7 <v_u_param_cylinder+0x1e7>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x2cff(%rip),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1332 <v_u_param_cylinder+0x222>
cmpl   $0x7,-0x4(%rbp)
jne    132d <v_u_param_cylinder+0x21d>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x2cc4(%rip),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1332 <v_u_param_cylinder+0x222>
jmp    1337 <v_u_param_cylinder+0x227>
jmp    133c <v_u_param_cylinder+0x22c>
jmp    1341 <v_u_param_cylinder+0x231>
jmp    1346 <v_u_param_cylinder+0x236>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v_u_param_cylinder>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x1(%rbx),%eax
cmp    $0x1,%eax
ja     1156 <v_u_param_cylinder+0x46>
mulsd  %xmm0,%xmm0
movsd  0xee3(%rip),%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd 0xedb(%rip),%xmm1
jbe    117b <v_u_param_cylinder+0x6b>
ucomisd %xmm0,%xmm1
jb     11a9 <v_u_param_cylinder+0x99>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
cmp    $0x1,%ebx
jne    11b7 <v_u_param_cylinder+0xa7>
jmp    1208 <v_u_param_cylinder+0xf8>
add    $0xfffffffc,%ebx
cmp    $0x3,%ebx
ja     11c6 <v_u_param_cylinder+0xb6>
lea    0xecb(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movsd  0xe9a(%rip),%xmm0
jmp    1208 <v_u_param_cylinder+0xf8>
movsd  0xe9d(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11b2 <v_u_param_cylinder+0xa2>
movapd 0xe6f(%rip),%xmm0
xorpd  %xmm1,%xmm0
movsd  0xe8b(%rip),%xmm2
ucomisd %xmm1,%xmm2
jb     11f6 <v_u_param_cylinder+0xe6>
sqrtsd %xmm0,%xmm0
jmp    11fb <v_u_param_cylinder+0xeb>
movapd %xmm1,%xmm0
call   1030 <sqrt@plt>
cmp    $0x1,%ebx
je     1208 <v_u_param_cylinder+0xf8>
cmp    $0x2,%ebx
jne    11c6 <v_u_param_cylinder+0xb6>
xorpd  0xe3c(%rip),%xmm0
jmp    1208 <v_u_param_cylinder+0xf8>
xorpd  %xmm0,%xmm0
jmp    1208 <v_u_param_cylinder+0xf8>
xorpd  0xe2c(%rip),%xmm0
mov    0x2e0d(%rip),%rax
subsd  (%rax),%xmm0
jmp    1208 <v_u_param_cylinder+0xf8>
mov    0x2e00(%rip),%rax
movsd  (%rax),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    1208 <v_u_param_cylinder+0xf8>
call   1030 <sqrt@plt>
xorpd  0xdfd(%rip),%xmm0
cmp    $0x1,%ebx
jne    11b7 <v_u_param_cylinder+0xa7>
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @v_u_param_cylinder(i32 %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double* %2, double** %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %47
14: ; preds = %11, %3
%15 = load double, double* %5
%16 = load double, double* %5
%17 = fneg double %15
%18 = call double @llvm.fmuladd.f64(double %17, double %16, double 1.000000e+00)
store double %18, double* %8
%19 = load double, double* %8
%20 = fcmp ogt double %19, 0x3D06849B86A12B9B
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load double, double* %8
%23 = call double @sqrt(double %22)
store double %23, double* %8
br label %34
24: ; preds = %14
%25 = load double, double* %8
%26 = fcmp olt double %25, 0xBD06849B86A12B9B
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load double, double* %8
%29 = fneg double %28
%30 = call double @sqrt(double %29)
%31 = fneg double %30
store double %31, double* %8
br label %33
32: ; preds = %24
store double 0.000000e+00, double* %8
br label %33
33: ; preds = %32, %27
br label %34
34: ; preds = %33, %21
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load double, double* %8
store double %38, double* %7
br label %46
39: ; preds = %34
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load double, double* %8
%44 = fneg double %43
store double %44, double* %7
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %37
br label %82
47: ; preds = %11
%48 = load i32, i32* %4
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %51
50: ; preds = %47
store double 0.000000e+00, double* %7
br label %81
51: ; preds = %47
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 4
br i1 %53, label %54, label %55
54: ; preds = %51
store double 1.000000e+00, double* %7
br label %80
55: ; preds = %51
%56 = load i32, i32* %4
%57 = icmp eq i32 %56, 5
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load double, double* %5
%60 = fneg double %59
store double %60, double* %7
br label %79
61: ; preds = %55
%62 = load i32, i32* %4
%63 = icmp eq i32 %62, 6
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = load double, double* %5
%66 = fneg double %65
%67 = load double, double* @M_PI
%68 = fsub double %66, %67
store double %68, double* %7
br label %78
69: ; preds = %61
%70 = load i32, i32* %4
%71 = icmp eq i32 %70, 7
br i1 %71, label %72, label %77
72: ; preds = %69
%73 = load double, double* %5
%74 = fneg double %73
%75 = load double, double* @M_PI
%76 = fadd double %74, %75
store double %76, double* %7
br label %77
77: ; preds = %72, %69
br label %78
78: ; preds = %77, %64
br label %79
79: ; preds = %78, %58
br label %80
80: ; preds = %79, %54
br label %81
81: ; preds = %80, %50
br label %82
82: ; preds = %81, %46
%83 = load double, double* %7
%84 = load double*, double** %6
store double %83, double* %84
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @v_u_param_cylinder(i32 %0, double %1, double* nocapture writeonly %2) {
%4 = add i32 %0, -1
%5 = icmp ult i32 %4, 2
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = fneg double %1
%8 = tail call double @llvm.fmuladd.f64(double %7, double %1, double 1.000000e+00)
%9 = fcmp ogt double %8, 0x3D06849B86A12B9B
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call double @sqrt(double %8)
br label %18
12: ; preds = %6
%13 = fcmp olt double %8, 0xBD06849B86A12B9B
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = fneg double %8
%16 = tail call double @sqrt(double %15)
%17 = fneg double %16
br label %18
18: ; preds = %12, %14, %10
%19 = phi double [ %11, %10 ], [ %17, %14 ], [ 0.000000e+00, %12 ]
switch i32 %0, label %33 [
i32 1, label %34
i32 2, label %20
]
20: ; preds = %18
%21 = fneg double %19
br label %34
22: ; preds = %3
switch i32 %0, label %34 [
i32 7, label %30
i32 4, label %23
i32 5, label %24
i32 6, label %26
]
23: ; preds = %22
br label %34
24: ; preds = %22
%25 = fneg double %1
br label %34
26: ; preds = %22
%27 = fneg double %1
%28 = load double, double* @M_PI
%29 = fsub double %27, %28
br label %34
30: ; preds = %22
%31 = load double, double* @M_PI
%32 = fsub double %31, %1
br label %34
33: ; preds = %18
br label %34
34: ; preds = %22, %18, %33, %24, %30, %26, %23, %20
%35 = phi double [ %21, %20 ], [ 1.000000e+00, %23 ], [ %25, %24 ], [ %29, %26 ], [ %32, %30 ], [ %19, %18 ], [ 0.000000e+00, %33 ], [ 0.000000e+00, %22 ]
store double %35, double* %2
ret void
}