#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 add(int, char **);
double divide(int, char **);
double mult(int, char **);
int /*<<< orphan*/ printf(char *, char *, double);
int /*<<< orphan*/ processOpts(int *, char **, int *, int *, int *, int *,
                               int *);
double sub(int, char **);
int main(int argc, char *argv[]) {
  int addFlag = 0;
  int subFlag = 0;
  int multFlag = 0;
  int divFlag = 0;
  int numOpts = 0;
  processOpts(&argc, argv, &addFlag, &subFlag, &multFlag, &divFlag, &numOpts);
  argv += numOpts;
  if (addFlag == 1)
    printf("%-12s %.3f\n", "Sum:", add(argc, argv));
  if (subFlag == 1)
    printf("%-12s %.3f\n", "Difference:", sub(argc, argv));
  if (multFlag == 1)
    printf("%-12s %.3f\n", "Product:", mult(argc, argv));
  if (divFlag == 1)
    printf("%-12s %.3f\n", "Quotient:", divide(argc, argv));
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
lea    -0x24(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <processOpts@plt>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11fc <main+0x9c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <add@plt>
lea    0xe10(%rip),%rdi
lea    0xe15(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1225 <main+0xc5>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <sub@plt>
lea    0xde7(%rip),%rdi
lea    0xdf1(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    124e <main+0xee>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <mult@plt>
lea    0xdbe(%rip),%rdi
lea    0xdd4(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,-0x20(%rbp)
jne    1277 <main+0x117>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <divide@plt>
lea    0xd95(%rip),%rdi
lea    0xdb4(%rip),%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %edi,0x8(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0x8(%rsp),%rdi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
call   1040 <processOpts@plt>
movslq 0xc(%rsp),%rax
lea    (%rbx,%rax,8),%rbx
cmpl   $0x1,0x1c(%rsp)
je     1207 <main+0xa7>
cmpl   $0x1,0x18(%rsp)
je     122d <main+0xcd>
cmpl   $0x1,0x14(%rsp)
je     1253 <main+0xf3>
cmpl   $0x1,0x10(%rsp)
jne    11ff <main+0x9f>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1050 <divide@plt>
lea    0xe0d(%rip),%rdi
lea    0xe2c(%rip),%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1030 <add@plt>
lea    0xde6(%rip),%rdi
lea    0xdeb(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,0x18(%rsp)
jne    11d2 <main+0x72>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1080 <sub@plt>
lea    0xdc0(%rip),%rdi
lea    0xdca(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,0x14(%rsp)
jne    11d9 <main+0x79>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1070 <mult@plt>
lea    0xd9a(%rip),%rdi
lea    0xdb0(%rip),%rsi
call   1060 <printf@plt>
cmpl   $0x1,0x10(%rsp)
je     11e0 <main+0x80>
jmp    11ff <main+0x9f>

LLVM IR (-O0):
@.str = [12 x i8] c"%-12s %.3f\0A\00"
@.str.1 = [5 x i8] c"Sum:\00"
@.str.2 = [12 x i8] c"Difference:\00"
@.str.3 = [9 x i8] c"Product:\00"
@.str.4 = [10 x i8] c"Quotient:\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i8**, i8*** %5
%12 = call i32 @processOpts(i32* %4, i8** %11, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%13 = load i32, i32* %10
%14 = load i8**, i8*** %5
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8*, i8** %14, i64 %15
store i8** %16, i8*** %5
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call double @add(i32 %20, i8** %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %22)
br label %24
24: ; preds = %19, %2
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call double @sub(i32 %28, i8** %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %32
32: ; preds = %27, %24
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* %4
%37 = load i8**, i8*** %5
%38 = call double @mult(i32 %36, i8** %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %38)
br label %40
40: ; preds = %35, %32
%41 = load i32, i32* %9
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* %4
%45 = load i8**, i8*** %5
%46 = call double @divide(i32 %44, i8** %45)
%47 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %46)
br label %48
48: ; preds = %43, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%-12s %.3f\0A\00"
@.str.1 = [5 x i8] c"Sum:\00"
@.str.2 = [12 x i8] c"Difference:\00"
@.str.3 = [9 x i8] c"Product:\00"
@.str.4 = [10 x i8] c"Quotient:\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%13 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%14 = call i32 @processOpts(i32* %3, i8** %1, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* %3
%22 = call double @add(i32 %21, i8** %17)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %22)
br label %24
24: ; preds = %20, %2
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %3
%29 = call double @sub(i32 %28, i8** %17)
%30 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %29)
br label %31
31: ; preds = %27, %24
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %3
%36 = call double @mult(i32 %35, i8** %17)
%37 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %36)
br label %38
38: ; preds = %34, %31
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* %3
%43 = call double @divide(i32 %42, i8** %17)
%44 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %43)
br label %45
45: ; preds = %41, %38
ret i32 0
}