#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 EXIT_FAILURE;
int EXIT_SUCCESS;
char *basename(char *);
double calc_hypotenuse(double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
double get_length(char *, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  double base, height, hypotenuse;
  if (argc > 3) {
    fprintf(stderr, "usage: %s [BASE [HEIGHT]]\n", basename(argv[0]));
    return EXIT_FAILURE;
  }
  if (argc > 1) {
    base = get_length("base", argv[1]);
  } else {
    base = get_length("base", NULL);
  }
  if (argc > 2) {
    height = get_length("height", argv[2]);
  } else {
    height = get_length("height", NULL);
  }
  hypotenuse = calc_hypotenuse(base, height);
  printf("The length of the hypotenuse is %.2f\n", hypotenuse);
  return EXIT_SUCCESS;
}


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)
cmpl   $0x3,-0x8(%rbp)
jle    11ab <main+0x5b>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <basename@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xe6b(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1256 <main+0x106>
cmpl   $0x1,-0x8(%rbp)
jle    11d3 <main+0x83>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe57(%rip),%rdi
call   1050 <get_length@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11e8 <main+0x98>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <get_length@plt>
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1210 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe1f(%rip),%rdi
call   1050 <get_length@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1225 <main+0xd5>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <get_length@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <calc_hypotenuse@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jl     1186 <main+0x36>
mov    0x2e7e(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rdi
call   1070 <basename@plt>
lea    0xe8d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2e54(%rip),%rax
jmp    11f5 <main+0xa5>
mov    %edi,%ebp
cmp    $0x1,%edi
jle    11ab <main+0x5b>
mov    0x8(%rbx),%rsi
lea    0xe83(%rip),%rdi
call   1050 <get_length@plt>
cmp    $0x2,%ebp
movsd  %xmm0,(%rsp)
jne    11c2 <main+0x72>
xor    %ebx,%ebx
jmp    11c6 <main+0x76>
lea    0xe69(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <get_length@plt>
movsd  %xmm0,(%rsp)
jmp    11c6 <main+0x76>
mov    0x10(%rbx),%rbx
lea    0xe53(%rip),%rdi
mov    %rbx,%rsi
call   1050 <get_length@plt>
movaps %xmm0,%xmm1
movsd  (%rsp),%xmm0
call   1030 <calc_hypotenuse@plt>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s [BASE [HEIGHT]]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"base\00"
@.str.2 = [7 x i8] c"height\00"
@.str.3 = [38 x i8] c"The length of the hypotenuse is %.2f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 3
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i8* @basename(i8* %15)
%17 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %46
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call double @get_length(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store double %26, double* %6
br label %29
27: ; preds = %19
%28 = call double @get_length(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* null)
store double %28, double* %6
br label %29
29: ; preds = %27, %22
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call double @get_length(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store double %36, double* %7
br label %39
37: ; preds = %29
%38 = call double @get_length(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* null)
store double %38, double* %7
br label %39
39: ; preds = %37, %32
%40 = load double, double* %6
%41 = load double, double* %7
%42 = call double @calc_hypotenuse(double %40, double %41)
store double %42, double* %8
%43 = load double, double* %8
%44 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %43)
%45 = load i32, i32* @EXIT_SUCCESS
store i32 %45, i32* %3
br label %46
46: ; preds = %39, %11
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s [BASE [HEIGHT]]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"base\00"
@.str.2 = [7 x i8] c"height\00"
@.str.3 = [38 x i8] c"The length of the hypotenuse is %.2f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i8* @basename(i8* %6)
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %27
9: ; preds = %2
%10 = icmp sgt i32 %0, 1
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call double @get_length(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* null)
br label %21
13: ; preds = %9
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call double @get_length(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = icmp eq i32 %0, 2
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
br label %21
21: ; preds = %13, %11, %18
%22 = phi i8* [ %20, %18 ], [ null, %11 ], [ null, %13 ]
%23 = phi double [ %16, %18 ], [ %12, %11 ], [ %16, %13 ]
%24 = tail call double @get_length(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%25 = tail call double @calc_hypotenuse(double %23, double %24)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), double %25)
br label %27
27: ; preds = %21, %4
%28 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %21 ]
%29 = load i32, i32* %28
ret i32 %29
}