#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;
double atof(char *);
int /*<<< orphan*/ computeHypotenuse(double, double);
int /*<<< orphan*/ computeOtherSide(double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ help();
int /*<<< orphan*/ isRightAngled(double, double, double);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  double hypotenuse, side1, side2;
  int opt;
  while ((opt = getopt(argc, argv, "chs")) != -1) {
    switch (opt) {
    case 's':
      if (argc == 4) {
        hypotenuse = atof(argv[2]);
        side1 = atof(argv[3]);
        fprintf(stdout, "The lenght of the other side is %lf\n",
                computeOtherSide(hypotenuse, side1));
      } else {
        help();
        return EXIT_FAILURE;
      }
      break;
    case 'c':
      if (argc == 5) {
        hypotenuse = atof(argv[2]);
        side1 = atof(argv[3]);
        side2 = atof(argv[4]);
        if (isRightAngled(hypotenuse, side1, side2))
          fprintf(stdout, "It\'s a right-angled triangle\n");
        else
          fprintf(stdout, "It is not a right-angled triangle\n");
      } else {
        help();
        return EXIT_FAILURE;
      }
      break;
    case 'h':
      if (argc == 4) {
        side1 = atof(argv[2]);
        side2 = atof(argv[3]);
        fprintf(stdout, "The lenght of the hypotenuse side is %lf\n",
                computeHypotenuse(side1, side2));
      } else {
        help();
        return EXIT_FAILURE;
      }
      break;
    default:
      help();
      return EXIT_FAILURE;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     13a6 <main+0x236>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x63,%eax
je     1259 <main+0xe9>
jmp    11b9 <main+0x49>
mov    -0x30(%rbp),%eax
sub    $0x68,%eax
je     130b <main+0x19b>
jmp    11ca <main+0x5a>
mov    -0x30(%rbp),%eax
sub    $0x73,%eax
jne    1389 <main+0x219>
jmp    11db <main+0x6b>
cmpl   $0x4,-0x8(%rbp)
jne    123c <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <computeOtherSide@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1254 <main+0xe4>
mov    $0x0,%al
call   1090 <help@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b2 <main+0x242>
jmp    13a1 <main+0x231>
cmpl   $0x5,-0x8(%rbp)
jne    12ee <main+0x17e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1050 <isRightAngled@plt>
cmp    $0x0,%eax
je     12d2 <main+0x162>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12e9 <main+0x179>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1306 <main+0x196>
mov    $0x0,%al
call   1090 <help@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b2 <main+0x242>
jmp    13a1 <main+0x231>
cmpl   $0x4,-0x8(%rbp)
jne    136c <main+0x1fc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    0x2c98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1060 <computeHypotenuse@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%edx
lea    0xd0a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1384 <main+0x214>
mov    $0x0,%al
call   1090 <help@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b2 <main+0x242>
jmp    13a1 <main+0x231>
mov    $0x0,%al
call   1090 <help@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b2 <main+0x242>
jmp    1186 <main+0x16>
mov    0x2c23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%r13d
lea    0xe75(%rip),%r14
mov    0x2e46(%rip),%r15
jmp    11a9 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0x67,%eax
jle    1210 <main+0xa0>
cmp    $0x68,%eax
je     1270 <main+0x100>
cmp    $0x73,%eax
jne    12ce <main+0x15e>
cmp    $0x4,%r13d
jne    12ce <main+0x15e>
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
mov    (%r15),%r12d
movsd  0x8(%rsp),%xmm0
call   1040 <computeOtherSide@plt>
mov    %r12d,%edi
lea    0xdf9(%rip),%rsi
jmp    11a0 <main+0x30>
nopl   (%rax)
cmp    $0x63,%eax
jne    12c0 <main+0x150>
cmp    $0x5,%r13d
jne    12ce <main+0x15e>
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x20(%rbx),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1050 <isRightAngled@plt>
mov    (%r15),%edi
test   %eax,%eax
je     12ad <main+0x13d>
lea    0xdbd(%rip),%rsi
jmp    12b4 <main+0x144>
xchg   %ax,%ax
cmp    $0x4,%r13d
jne    12ce <main+0x15e>
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
mov    (%r15),%ebp
movsd  0x8(%rsp),%xmm0
call   1060 <computeHypotenuse@plt>
mov    %ebp,%edi
lea    0xdc2(%rip),%rsi
jmp    11a0 <main+0x30>
lea    0xd93(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11a9 <main+0x39>
cmp    $0xffffffff,%eax
jne    12ce <main+0x15e>
mov    0x2d04(%rip),%rax
jmp    12dc <main+0x16c>
xor    %eax,%eax
call   1090 <help@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"chs\00"
@stdout = global i32 0
@.str.1 = [37 x i8] c"The lenght of the other side is %lf\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"It's a right-angled triangle\0A\00"
@.str.3 = [35 x i8] c"It is not a right-angled triangle\0A\00"
@.str.4 = [42 x i8] c"The lenght of the hypotenuse side is %lf\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %94, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %95
15: ; preds = %10
%16 = load i32, i32* %9
switch i32 %16, label %91 [
i32 115, label %17
i32 99, label %38
i32 104, label %70
]
17: ; preds = %15
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 4
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call double @atof(i8* %23)
store double %24, double* %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call double @atof(i8* %27)
store double %28, double* %7
%29 = load i32, i32* @stdout
%30 = load double, double* %6
%31 = load double, double* %7
%32 = call i32 @computeOtherSide(double %30, double %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %37
34: ; preds = %17
%35 = call i32 (...) @help()
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %97
37: ; preds = %20
br label %94
38: ; preds = %15
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 5
br i1 %40, label %41, label %66
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call double @atof(i8* %44)
store double %45, double* %6
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call double @atof(i8* %48)
store double %49, double* %7
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 4
%52 = load i8*, i8** %51
%53 = call double @atof(i8* %52)
store double %53, double* %8
%54 = load double, double* %6
%55 = load double, double* %7
%56 = load double, double* %8
%57 = call i32 @isRightAngled(double %54, double %55, double %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %41
%60 = load i32, i32* @stdout
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %65
62: ; preds = %41
%63 = load i32, i32* @stdout
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %62, %59
br label %69
66: ; preds = %38
%67 = call i32 (...) @help()
%68 = load i32, i32* @EXIT_FAILURE
store i32 %68, i32* %3
br label %97
69: ; preds = %65
br label %94
70: ; preds = %15
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 4
br i1 %72, label %73, label %87
73: ; preds = %70
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 2
%76 = load i8*, i8** %75
%77 = call double @atof(i8* %76)
store double %77, double* %7
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 3
%80 = load i8*, i8** %79
%81 = call double @atof(i8* %80)
store double %81, double* %8
%82 = load i32, i32* @stdout
%83 = load double, double* %7
%84 = load double, double* %8
%85 = call i32 @computeHypotenuse(double %83, double %84)
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %85)
br label %90
87: ; preds = %70
%88 = call i32 (...) @help()
%89 = load i32, i32* @EXIT_FAILURE
store i32 %89, i32* %3
br label %97
90: ; preds = %73
br label %94
91: ; preds = %15
%92 = call i32 (...) @help()
%93 = load i32, i32* @EXIT_FAILURE
store i32 %93, i32* %3
br label %97
94: ; preds = %90, %69, %37
br label %10
95: ; preds = %10
%96 = load i32, i32* @EXIT_SUCCESS
store i32 %96, i32* %3
br label %97
97: ; preds = %95, %91, %87, %66, %34
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str = [4 x i8] c"chs\00"
@stdout = global i32 0
@.str.1 = [37 x i8] c"The lenght of the other side is %lf\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [30 x i8] c"It's a right-angled triangle\0A\00"
@.str.3 = [35 x i8] c"It is not a right-angled triangle\0A\00"
@.str.4 = [42 x i8] c"The lenght of the hypotenuse side is %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 4
%4 = getelementptr inbounds i8*, i8** %1, i64 2
%5 = getelementptr inbounds i8*, i8** %1, i64 3
%6 = icmp eq i32 %0, 5
%7 = getelementptr inbounds i8*, i8** %1, i64 4
br label %8
8: ; preds = %34, %2
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %44 [
i32 -1, label %46
i32 115, label %10
i32 99, label %19
i32 104, label %35
]
10: ; preds = %8
br i1 %3, label %11, label %44
11: ; preds = %10
%12 = load i8*, i8** %4
%13 = tail call double @atof(i8* %12)
%14 = load i8*, i8** %5
%15 = tail call double @atof(i8* %14)
%16 = load i32, i32* @stdout
%17 = tail call i32 @computeOtherSide(double %13, double %15)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %34
19: ; preds = %8
br i1 %6, label %20, label %44
20: ; preds = %19
%21 = load i8*, i8** %4
%22 = tail call double @atof(i8* %21)
%23 = load i8*, i8** %5
%24 = tail call double @atof(i8* %23)
%25 = load i8*, i8** %7
%26 = tail call double @atof(i8* %25)
%27 = tail call i32 @isRightAngled(double %22, double %24, double %26)
%28 = icmp eq i32 %27, 0
%29 = load i32, i32* @stdout
br i1 %28, label %32, label %30
30: ; preds = %20
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %34
32: ; preds = %20
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %30, %36, %11
br label %8
35: ; preds = %8
br i1 %3, label %36, label %44
36: ; preds = %35
%37 = load i8*, i8** %4
%38 = tail call double @atof(i8* %37)
%39 = load i8*, i8** %5
%40 = tail call double @atof(i8* %39)
%41 = load i32, i32* @stdout
%42 = tail call i32 @computeHypotenuse(double %38, double %40)
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %34
44: ; preds = %8, %35, %19, %10
%45 = tail call i32 (...) @help()
br label %46
46: ; preds = %8, %44
%47 = phi i32* [ @EXIT_FAILURE, %44 ], [ @EXIT_SUCCESS, %8 ]
%48 = load i32, i32* %47
ret i32 %48
}