#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 atof(char *);
int /*<<< orphan*/ blhToxyz(double *, double *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  double xyz[3] = {0.0}, blh[3] = {0.0};
  if (argc < 4) {
    fprintf(stdout, "blh2xyz b(d) l(d) h\n");
    return -1;
  }
  blh[0] = atof(argv[1]) * (3.1415926535897932 / 180.0);
  blh[1] = atof(argv[2]) * (3.1415926535897932 / 180.0);
  blh[2] = atof(argv[3]);
  blhToxyz(blh, xyz);
  printf("%lf\n%lf\n%lf\n", xyz[0], xyz[1], xyz[2]);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
cmpl   $0x4,-0x8(%rbp)
jge    11b1 <main+0x61>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  0xe1c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <blhToxyz@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
cmp    $0x3,%edi
jg     1178 <main+0x38>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11e9 <main+0xa9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movapd %xmm0,0x20(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  0xe5b(%rip),%xmm1
movapd %xmm1,0x30(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x40(%rsp)
lea    0x30(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <blhToxyz@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [21 x i8] c"blh2xyz b(d) l(d) h\0A\00"
@.str.1 = [13 x i8] c"%lf\0A%lf\0A%lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x double]
%7 = alloca [3 x double]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [3 x double]* %6 to i8*
%9 = bitcast [3 x double]* %7 to i8*
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %43
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call double @atof(i8* %18)
%20 = fmul double %19, 0x3F91DF46A2529D39
%21 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
store double %20, double* %21
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call double @atof(i8* %24)
%26 = fmul double %25, 0x3F91DF46A2529D39
%27 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
store double %26, double* %27
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call double @atof(i8* %30)
%32 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %31, double* %32
%33 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%34 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%35 = call i32 @blhToxyz(double* %33, double* %34)
%36 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%37 = load double, double* %36
%38 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%39 = load double, double* %38
%40 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%41 = load double, double* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %37, double %39, double %41)
store i32 1, i32* %3
br label %43
43: ; preds = %15, %12
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [21 x i8] c"blh2xyz b(d) l(d) h\0A\00"
@.str.1 = [13 x i8] c"%lf\0A%lf\0A%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %3 to i8*
%6 = bitcast [3 x double]* %4 to i8*
%7 = icmp slt i32 %0, 4
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %35
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call double @atof(i8* %13)
%15 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call double @atof(i8* %17)
%19 = insertelement <2 x double> poison, double %14, i64 0
%20 = insertelement <2 x double> %19, double %18, i64 1
%21 = fmul <2 x double> %20, <double 0x3F91DF46A2529D39, double 0x3F91DF46A2529D39>
%22 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %21, <2 x double>* %22
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call double @atof(i8* %24)
%26 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %25, double* %26
%27 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%28 = call i32 @blhToxyz(double* %15, double* %27)
%29 = load double, double* %27
%30 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%31 = load double, double* %30
%32 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%33 = load double, double* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %29, double %31, double %33)
br label %35
35: ; preds = %11, %8
%36 = phi i32 [ -1, %8 ], [ 1, %11 ]
ret i32 %36
}