#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 EOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rvec2st(float, float, float, float *, float *);
int scanf(char *, float *, float *);
int /*<<< orphan*/ st2rvec(float, float, float *, float *, float *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  float s, t;
  float x, y, z;
  int count;
  printf("\nYOU ENTER S & T SPHERE MAP TEXTURE COORDINATES...\n");
  printf("\n  I CONVERT IT TO A NORMALIZED REFLECTION VECTOR");
  printf("\n      (AND CONVERT BACK!)\n\n");
  while (!feof(stdin)) {
    printf("(s,t) > ");
    count = scanf("%f%f", &s, &t);
    if (count == EOF) {
      break;
    } else if (count == 2) {
      printf("READ s=%f, t=%f\n\n", s, t);
      st2rvec(s, t, &x, &y, &z);
      printf("CONVERTING TO REFLECTION VECTOR:\n");
      printf("  x=%f, y=%f, z=%f\n\n", x, y, z);
      printf("CONVERTING BACK TO TEXTURE COORDINATE:\n");
      rvec2st(x, y, z, &s, &t);
      printf("  s=%f, t=%f\n\n", s, t);
    } else {
      printf("BAD INPUT!\n\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <main+0x63>
jmp    12d7 <main+0x187>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <scanf@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%eax
jne    11ef <main+0x9f>
jmp    12d7 <main+0x187>
cmpl   $0x2,-0x28(%rbp)
jne    12ba <main+0x16a>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe7f(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1070 <st2rvec@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x24(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe61(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <rvec2st@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe54(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12cd <main+0x17d>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x187>
jmp    12d2 <main+0x182>
jmp    1190 <main+0x40>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4d(%rip),%r14
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
je     11b8 <main+0x58>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%r12
lea    0x4(%rsp),%rbx
lea    0xe89(%rip),%r13
lea    0xf22(%rip),%r15
lea    0xe90(%rip),%rbp
nopw   0x0(%rax,%rax,1)
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0x2dd9(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <main+0x47>
cmp    $0x2,%eax
jne    12e2 <main+0x182>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe11(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1080 <st2rvec@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r13,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <rvec2st@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %rbp,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
je     11e0 <main+0x80>
jmp    11a7 <main+0x47>
lea    0xddc(%rip),%rdi
call   1030 <puts@plt>
jmp    11a7 <main+0x47>

LLVM IR (-O0):
@.str = [52 x i8] c"\0AYOU ENTER S & T SPHERE MAP TEXTURE COORDINATES...\0A\00"
@.str.1 = [50 x i8] c"\0A I CONVERT IT TO A NORMALIZED REFLECTION VECTOR\00"
@.str.2 = [29 x i8] c"\0A (AND CONVERT BACK!)\0A\0A\00"
@stdin = global i32 0
@.str.3 = [9 x i8] c"(s,t) > \00"
@.str.4 = [5 x i8] c"%f%f\00"
@EOF = global i32 0
@.str.5 = [18 x i8] c"READ s=%f, t=%f\0A\0A\00"
@.str.6 = [34 x i8] c"CONVERTING TO REFLECTION VECTOR:\0A\00"
@.str.7 = [21 x i8] c" x=%f, y=%f, z=%f\0A\0A\00"
@.str.8 = [40 x i8] c"CONVERTING BACK TO TEXTURE COORDINATE:\0A\00"
@.str.9 = [15 x i8] c" s=%f, t=%f\0A\0A\00"
@.str.10 = [13 x i8] c"BAD INPUT!\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %60, %2
%16 = load i32, i32* @stdin
%17 = call i32 @feof(i32 %16)
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
br i1 %19, label %20, label %61
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), float* %6, float* %7)
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %20
br label %61
27: ; preds = %20
%28 = load i32, i32* %11
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %57
30: ; preds = %27
%31 = load float, float* %6
%32 = fpext float %31 to double
%33 = load float, float* %7
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %32, double %34)
%36 = load float, float* %6
%37 = load float, float* %7
%38 = call i32 @st2rvec(float %36, float %37, float* %8, float* %9, float* %10)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = load float, float* %9
%43 = fpext float %42 to double
%44 = load float, float* %10
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), double %41, double %43, double %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%48 = load float, float* %8
%49 = load float, float* %9
%50 = load float, float* %10
%51 = call i32 @rvec2st(float %48, float %49, float %50, float* %6, float* %7)
%52 = load float, float* %6
%53 = fpext float %52 to double
%54 = load float, float* %7
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %53, double %55)
br label %59
57: ; preds = %27
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %61
59: ; preds = %30
br label %60
60: ; preds = %59
br label %15
61: ; preds = %57, %26, %15
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [50 x i8] c"\0A I CONVERT IT TO A NORMALIZED REFLECTION VECTOR\00"
@stdin = global i32 0
@.str.3 = [9 x i8] c"(s,t) > \00"
@.str.4 = [5 x i8] c"%f%f\00"
@EOF = global i32 0
@.str.5 = [18 x i8] c"READ s=%f, t=%f\0A\0A\00"
@.str.7 = [21 x i8] c" x=%f, y=%f, z=%f\0A\0A\00"
@.str.9 = [15 x i8] c" s=%f, t=%f\0A\0A\00"
@str = [51 x i8] c"\0AYOU ENTER S & T SPHERE MAP TEXTURE COORDINATES...\00"
@str.11 = [28 x i8] c"\0A (AND CONVERT BACK!)\0A\00"
@str.12 = [12 x i8] c"BAD INPUT!\0A\00"
@str.13 = [33 x i8] c"CONVERTING TO REFLECTION VECTOR:\00"
@str.14 = [39 x i8] c"CONVERTING BACK TO TEXTURE COORDINATE:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = bitcast float* %6 to i8*
%12 = bitcast float* %7 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @feof(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %58
19: ; preds = %2, %26
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), float* %3, float* %4)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %58, label %24
24: ; preds = %19
%25 = icmp eq i32 %21, 2
br i1 %25, label %26, label %56
26: ; preds = %24
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = load float, float* %4
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %28, double %30)
%32 = load float, float* %3
%33 = load float, float* %4
%34 = call i32 @st2rvec(float %32, float %33, float* %5, float* %6, float* %7)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = load float, float* %6
%39 = fpext float %38 to double
%40 = load float, float* %7
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), double %37, double %39, double %41)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.14, i64 0, i64 0))
%44 = load float, float* %5
%45 = load float, float* %6
%46 = load float, float* %7
%47 = call i32 @rvec2st(float %44, float %45, float %46, float* %3, float* %4)
%48 = load float, float* %3
%49 = fpext float %48 to double
%50 = load float, float* %4
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), double %49, double %51)
%53 = load i32, i32* @stdin
%54 = call i32 @feof(i32 %53)
%55 = icmp eq i32 %54, 0
br i1 %55, label %19, label %58
56: ; preds = %24
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0))
br label %58
58: ; preds = %26, %19, %2, %56
ret i32 0
}