#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *);
double sqrt(double);
int main(void) {
  double a[3];
  double b[3];
  printf("Input a and b:\n");
  scanf("%lf%lf", a, a + 1);
  scanf("%lf%lf", b, b + 1);
  printf("a=(%lf %lf)\n", a[0], a[1]);
  printf("b=(%lf %lf)\n", b[0], b[1]);
  printf("max(a,b):%lf\n", ((a[0] > a[1]) ? a[0] : a[1]));
  printf("min(a,b):%lf\n", ((a[0] < a[1]) ? a[0] : a[1]));
  printf("dot(a,b):%lf\n", (a[0] * b[0] + a[1] * b[1]));
  (a[0] = -b[1], a[1] = b[0]);
  printf("a=(%lf %lf)\n", a[0], a[1]);
  printf("dot(a,b) after normal:%lf\n", (a[0] * b[0] + a[1] * b[1]));
  printf("len(a)::%lf\n", (sqrt(a[0] * a[0] + a[1] * a[1])));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x20(%rbp),%rdx
add    $0x8,%rdx
lea    0xeb0(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    -0x40(%rbp),%rdx
add    $0x8,%rdx
lea    0xe98(%rip),%rdi
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe89(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe7e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11cc <main+0x9c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11d6 <main+0xa6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    120c <main+0xdc>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1216 <main+0xe6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xe1d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe01(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xd88(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xda2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
lea    0xd8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdx
lea    0xeb3(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x28(%rsp),%rdx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
lea    0xe7b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
maxsd  0x8(%rsp),%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
minsd  0x8(%rsp),%xmm0
lea    0xe64(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
movsd  (%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
lea    0xe49(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x28(%rsp),%xmm0
xorps  0xde8(%rip),%xmm0
movlps %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
movsd  (%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1282 <main+0x142>
sqrtsd %xmm0,%xmm0
jmp    1287 <main+0x147>
call   1060 <sqrt@plt>
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Input a and b:\0A\00"
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [13 x i8] c"a=(%lf %lf)\0A\00"
@.str.3 = [13 x i8] c"b=(%lf %lf)\0A\00"
@.str.4 = [14 x i8] c"max(a,b):%lf\0A\00"
@.str.5 = [14 x i8] c"min(a,b):%lf\0A\00"
@.str.6 = [14 x i8] c"dot(a,b):%lf\0A\00"
@.str.7 = [27 x i8] c"dot(a,b) after normal:%lf\0A\00"
@.str.8 = [13 x i8] c"len(a)::%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x double]
%3 = alloca [3 x double]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%7 = getelementptr inbounds double, double* %6, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %5, double* %7)
%9 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%10 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %9, double* %11)
%13 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%16 = load double, double* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %14, double %16)
%18 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%21 = load double, double* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %19, double %21)
%23 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%24 = load double, double* %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%26 = load double, double* %25
%27 = fcmp ogt double %24, %26
br i1 %27, label %28, label %31
28: ; preds = %0
%29 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%30 = load double, double* %29
br label %34
31: ; preds = %0
%32 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%33 = load double, double* %32
br label %34
34: ; preds = %31, %28
%35 = phi double [ %30, %28 ], [ %33, %31 ]
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %35)
%37 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%38 = load double, double* %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%40 = load double, double* %39
%41 = fcmp olt double %38, %40
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%44 = load double, double* %43
br label %48
45: ; preds = %34
%46 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%47 = load double, double* %46
br label %48
48: ; preds = %45, %42
%49 = phi double [ %44, %42 ], [ %47, %45 ]
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %49)
%51 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%52 = load double, double* %51
%53 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%54 = load double, double* %53
%55 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%56 = load double, double* %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%58 = load double, double* %57
%59 = fmul double %56, %58
%60 = call double @llvm.fmuladd.f64(double %52, double %54, double %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %60)
%62 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%63 = load double, double* %62
%64 = fneg double %63
%65 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
store double %64, double* %65
%66 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%67 = load double, double* %66
%68 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
store double %67, double* %68
%69 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%70 = load double, double* %69
%71 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%72 = load double, double* %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %70, double %72)
%74 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%75 = load double, double* %74
%76 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%77 = load double, double* %76
%78 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%79 = load double, double* %78
%80 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%81 = load double, double* %80
%82 = fmul double %79, %81
%83 = call double @llvm.fmuladd.f64(double %75, double %77, double %82)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %83)
%85 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%86 = load double, double* %85
%87 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%88 = load double, double* %87
%89 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%90 = load double, double* %89
%91 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%92 = load double, double* %91
%93 = fmul double %90, %92
%94 = call double @llvm.fmuladd.f64(double %86, double %88, double %93)
%95 = call double @sqrt(double %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %95)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [13 x i8] c"a=(%lf %lf)\0A\00"
@.str.3 = [13 x i8] c"b=(%lf %lf)\0A\00"
@.str.4 = [14 x i8] c"max(a,b):%lf\0A\00"
@.str.5 = [14 x i8] c"min(a,b):%lf\0A\00"
@.str.6 = [14 x i8] c"dot(a,b):%lf\0A\00"
@.str.7 = [27 x i8] c"dot(a,b) after normal:%lf\0A\00"
@.str.8 = [13 x i8] c"len(a)::%lf\0A\00"
@str = [15 x i8] c"Input a and b:\00"
define i32 @main() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = bitcast [3 x double]* %1 to i8*
%4 = bitcast [3 x double]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%7 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %6, double* %7)
%9 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%10 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %9, double* %10)
%12 = load double, double* %6
%13 = load double, double* %7
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %12, double %13)
%15 = load double, double* %9
%16 = load double, double* %10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %15, double %16)
%18 = load double, double* %6
%19 = load double, double* %7
%20 = fcmp ogt double %18, %19
%21 = select i1 %20, double %18, double %19
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %21)
%23 = load double, double* %6
%24 = load double, double* %7
%25 = fcmp olt double %23, %24
%26 = select i1 %25, double %23, double %24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = load double, double* %6
%29 = load double, double* %9
%30 = load double, double* %7
%31 = load double, double* %10
%32 = fmul double %30, %31
%33 = call double @llvm.fmuladd.f64(double %28, double %29, double %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %33)
%35 = load double, double* %10
%36 = fneg double %35
store double %36, double* %6
%37 = load double, double* %9
store double %37, double* %7
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %36, double %37)
%39 = load double, double* %6
%40 = load double, double* %9
%41 = load double, double* %7
%42 = load double, double* %10
%43 = fmul double %41, %42
%44 = call double @llvm.fmuladd.f64(double %39, double %40, double %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %44)
%46 = load double, double* %6
%47 = load double, double* %7
%48 = fmul double %47, %47
%49 = call double @llvm.fmuladd.f64(double %46, double %46, double %48)
%50 = call double @sqrt(double %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %50)
ret i32 0
}