#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 dot(double *, double *);
double len(double *);
int /*<<< orphan*/ normal(double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, 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", dot(a, b));
  normal(a, b);
  printf("a=(%lf %lf)\n", a[0], a[1]);
  printf("dot(a,b) after normal:%lf\n", dot(a, b));
  printf("len(a)::%lf\n", len(a));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x20(%rbp),%rdx
add    $0x8,%rdx
lea    0xe90(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    -0x40(%rbp),%rdx
add    $0x8,%rdx
lea    0xe78(%rip),%rdi
call   1060 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe69(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe5e(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11ec <main+0x9c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11f6 <main+0xa6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122c <main+0xdc>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1236 <main+0xe6>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <dot@plt>
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <normal@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xd95(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <dot@plt>
lea    0xdbe(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <len@plt>
lea    0xdc2(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xf01(%rip),%rdi
call   1050 <puts@plt>
lea    0x8(%rsp),%rdx
lea    0xe7d(%rip),%rbx
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
lea    0x28(%rsp),%rdx
lea    0x20(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe4f(%rip),%r15
mov    %r15,%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
lea    0xe3f(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movsd  (%rsp),%xmm0
maxsd  0x8(%rsp),%xmm0
lea    0xe33(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  (%rsp),%xmm0
minsd  0x8(%rsp),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <dot@plt>
lea    0xe1d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <normal@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %r15,%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <dot@plt>
lea    0xdf2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12,%rdi
call   1030 <len@plt>
lea    0xdf7(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%53 = call double @dot(double* %51, double* %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %53)
%55 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%56 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%57 = call i32 @normal(double* %55, double* %56)
%58 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%59 = load double, double* %58
%60 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%61 = load double, double* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %59, double %61)
%63 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%64 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%65 = call double @dot(double* %63, double* %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %65)
%67 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%68 = call double @len(double* %67)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %68)
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 = call double @dot(double* %6, double* %9)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %28)
%30 = call i32 @normal(double* %6, double* %9)
%31 = load double, double* %6
%32 = load double, double* %7
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %31, double %32)
%34 = call double @dot(double* %6, double* %9)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %34)
%36 = call double @len(double* %6)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double %36)
ret i32 0
}