#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, int, double);
int /*<<< orphan*/ stdin;
double strtod(char *, char **);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  double flash = 0;
  double sram = 0;
  double text = 0;
  double data = 0;
  double bss = 0;
  int opt;
  char *end;
  char *input = NULL;
  size_t count = 0;
  while ((opt = getopt(argc, argv, "s:f:")) != -1) {
    switch (opt) {
    case 's':
      sram = strtod(optarg, &end);
      break;
    case 'f':
      flash = strtod(optarg, &end);
      break;
    default:
      usage();
      return -1;
    }
  }
  if (flash <= 0 || sram <= 0)
    goto error;
  ssize_t bytes = getline(&input, &count, stdin);
  if (bytes == -1) {
    free(input);
    input = NULL;
    goto error;
  }
  free(input);
  input = NULL;
  bytes = getline(&input, &count, stdin);
  char *ptr = input;
  if (bytes == -1) {
    free(input);
    input = NULL;
    ptr = NULL;
    goto error;
  }
  text = strtod(ptr, &end);
  if (text < 0) {
    free(input);
    input = NULL;
    ptr = NULL;
    goto error;
  }
  ptr = end;
  data = strtod(ptr, &end);
  if (data < 0) {
    free(input);
    input = NULL;
    ptr = NULL;
    goto error;
  }
  ptr = end;
  bss = strtod(ptr, &end);
  if (bss < 0) {
    free(input);
    input = NULL;
    ptr = NULL;
    goto error;
  }
  printf("Flash usage: %d bytes, %.1f %%\n", (int)(text + data),
         ((text + data) / flash) * 100.0);
  printf("Ram usage:   %d bytes, %.1f %%\n", (int)(data + bss),
         ((data + bss) / sram) * 100.0);
  return 0;
error:
  usage();
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4c(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     1244 <main+0xe4>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x66,%eax
je     120f <main+0xaf>
jmp    11e1 <main+0x81>
mov    -0x6c(%rbp),%eax
sub    $0x73,%eax
jne    122c <main+0xcc>
jmp    11f2 <main+0x92>
mov    0x2dff(%rip),%rax
mov    (%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    123f <main+0xdf>
mov    0x2de2(%rip),%rax
mov    (%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    123f <main+0xdf>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1446 <main+0x2e6>
jmp    11ae <main+0x4e>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1260 <main+0x100>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1265 <main+0x105>
jmp    1438 <main+0x2d8>
mov    0x2d74(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    129e <main+0x13e>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
jmp    1438 <main+0x2d8>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
mov    0x2d2a(%rip),%rax
mov    (%rax),%edx
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    12f8 <main+0x198>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x68(%rbp)
jmp    1438 <main+0x2d8>
mov    -0x68(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1336 <main+0x1d6>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x68(%rbp)
jmp    1438 <main+0x2d8>
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    137c <main+0x21c>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x68(%rbp)
jmp    1438 <main+0x2d8>
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    13c2 <main+0x262>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x68(%rbp)
jmp    1438 <main+0x2d8>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xc19(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xc1b(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xbe4(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xc06(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1446 <main+0x2e6>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x30(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe7c(%rip),%r14
mov    0x2e5d(%rip),%r12
lea    0x18(%rsp),%r15
xorpd  %xmm0,%xmm0
jmp    11bc <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
mov    (%r12),%rdi
mov    %r15,%rsi
call   1040 <strtod@plt>
movsd  %xmm0,0x20(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0x73,%eax
je     11b0 <main+0x50>
cmp    $0xffffffff,%eax
je     11f6 <main+0x96>
cmp    $0x66,%eax
jne    12ce <main+0x16e>
mov    (%r12),%rdi
mov    %r15,%rsi
call   1040 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
jmp    11c2 <main+0x62>
xorpd  %xmm0,%xmm0
ucomisd 0x10(%rsp),%xmm0
jae    12ce <main+0x16e>
ucomisd 0x20(%rsp),%xmm0
jae    12ce <main+0x16e>
mov    0x2dc7(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x8(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1080 <getline@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,0x8(%rsp)
cmp    $0xffffffff,%ebx
je     12ce <main+0x16e>
mov    0x0(%rbp),%edx
lea    0x8(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
cmp    $0xffffffff,%eax
je     12c0 <main+0x160>
lea    0x18(%rsp),%rsi
call   1040 <strtod@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     12bb <main+0x15b>
movsd  %xmm0,0x38(%rsp)
mov    0x18(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1040 <strtod@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     12bb <main+0x15b>
movsd  %xmm0,0x28(%rsp)
mov    0x18(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1040 <strtod@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12e7 <main+0x187>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0xffffffff,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movsd  0x38(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%esi
divsd  0x10(%rsp),%xmm0
mulsd  0xcfb(%rip),%xmm0
lea    0xd09(%rip),%rdi
movsd  %xmm1,0x10(%rsp)
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%esi
divsd  0x20(%rsp),%xmm0
mulsd  0xccb(%rip),%xmm0
lea    0xcf9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
jmp    12da <main+0x17a>

LLVM IR (-O0):
@.str = [5 x i8] c"s:f:\00"
@optarg = global i8* null
@stdin = global i32 0
@.str.1 = [32 x i8] c"Flash usage: %d bytes, %.1f %%\0A\00"
@.str.2 = [32 x i8] c"Ram usage: %d bytes, %.1f %%\0A\00"
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 double
%10 = alloca double
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i8* null, i8** %13
store i64 0, i64* %14
br label %17
17: ; preds = %32, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %11
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %33
22: ; preds = %17
%23 = load i32, i32* %11
switch i32 %23, label %30 [
i32 115, label %24
i32 102, label %27
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
%26 = call double @strtod(i8* %25, i8** %12)
store double %26, double* %7
br label %32
27: ; preds = %22
%28 = load i8*, i8** @optarg
%29 = call double @strtod(i8* %28, i8** %12)
store double %29, double* %6
br label %32
30: ; preds = %22
%31 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %110
32: ; preds = %27, %24
br label %17
33: ; preds = %17
%34 = load double, double* %6
%35 = fcmp ole double %34, 0.000000e+00
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load double, double* %7
%38 = fcmp ole double %37, 0.000000e+00
br i1 %38, label %39, label %40
39: ; preds = %36, %33
br label %108
40: ; preds = %36
%41 = load i32, i32* @stdin
%42 = call i32 @getline(i8** %13, i64* %14, i32 %41)
store i32 %42, i32* %15
%43 = load i32, i32* %15
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i8*, i8** %13
%47 = call i32 @free(i8* %46)
store i8* null, i8** %13
br label %108
48: ; preds = %40
%49 = load i8*, i8** %13
%50 = call i32 @free(i8* %49)
store i8* null, i8** %13
%51 = load i32, i32* @stdin
%52 = call i32 @getline(i8** %13, i64* %14, i32 %51)
store i32 %52, i32* %15
%53 = load i8*, i8** %13
store i8* %53, i8** %16
%54 = load i32, i32* %15
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %48
%57 = load i8*, i8** %13
%58 = call i32 @free(i8* %57)
store i8* null, i8** %13
store i8* null, i8** %16
br label %108
59: ; preds = %48
%60 = load i8*, i8** %16
%61 = call double @strtod(i8* %60, i8** %12)
store double %61, double* %8
%62 = load double, double* %8
%63 = fcmp olt double %62, 0.000000e+00
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load i8*, i8** %13
%66 = call i32 @free(i8* %65)
store i8* null, i8** %13
store i8* null, i8** %16
br label %108
67: ; preds = %59
%68 = load i8*, i8** %12
store i8* %68, i8** %16
%69 = load i8*, i8** %16
%70 = call double @strtod(i8* %69, i8** %12)
store double %70, double* %9
%71 = load double, double* %9
%72 = fcmp olt double %71, 0.000000e+00
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = load i8*, i8** %13
%75 = call i32 @free(i8* %74)
store i8* null, i8** %13
store i8* null, i8** %16
br label %108
76: ; preds = %67
%77 = load i8*, i8** %12
store i8* %77, i8** %16
%78 = load i8*, i8** %16
%79 = call double @strtod(i8* %78, i8** %12)
store double %79, double* %10
%80 = load double, double* %10
%81 = fcmp olt double %80, 0.000000e+00
br i1 %81, label %82, label %85
82: ; preds = %76
%83 = load i8*, i8** %13
%84 = call i32 @free(i8* %83)
store i8* null, i8** %13
store i8* null, i8** %16
br label %108
85: ; preds = %76
%86 = load double, double* %8
%87 = load double, double* %9
%88 = fadd double %86, %87
%89 = fptosi double %88 to i32
%90 = load double, double* %8
%91 = load double, double* %9
%92 = fadd double %90, %91
%93 = load double, double* %6
%94 = fdiv double %92, %93
%95 = fmul double %94, 1.000000e+02
%96 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %89, double %95)
%97 = load double, double* %9
%98 = load double, double* %10
%99 = fadd double %97, %98
%100 = fptosi double %99 to i32
%101 = load double, double* %9
%102 = load double, double* %10
%103 = fadd double %101, %102
%104 = load double, double* %7
%105 = fdiv double %103, %104
%106 = fmul double %105, 1.000000e+02
%107 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %100, double %106)
store i32 0, i32* %3
br label %110
108: ; preds = %82, %73, %64, %56, %45, %39
%109 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %110
110: ; preds = %108, %85, %30
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
@.str = [5 x i8] c"s:f:\00"
@optarg = global i8* null
@stdin = global i32 0
@.str.1 = [32 x i8] c"Flash usage: %d bytes, %.1f %%\0A\00"
@.str.2 = [32 x i8] c"Ram usage: %d bytes, %.1f %%\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
br label %9
9: ; preds = %18, %2
%10 = phi double [ %20, %18 ], [ 0.000000e+00, %2 ]
%11 = phi double [ %13, %18 ], [ 0.000000e+00, %2 ]
br label %12
12: ; preds = %9, %15
%13 = phi double [ %17, %15 ], [ %11, %9 ]
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %14, label %21 [
i32 -1, label %23
i32 115, label %15
i32 102, label %18
]
15: ; preds = %12
%16 = load i8*, i8** @optarg
%17 = call double @strtod(i8* %16, i8** %3)
br label %12
18: ; preds = %12
%19 = load i8*, i8** @optarg
%20 = call double @strtod(i8* %19, i8** %3)
br label %9
21: ; preds = %12
%22 = tail call i32 (...) @usage()
br label %73
23: ; preds = %12
%24 = fcmp ole double %10, 0.000000e+00
%25 = fcmp ole double %13, 0.000000e+00
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %71, label %27
27: ; preds = %23
%28 = load i32, i32* @stdin
%29 = call i32 @getline(i8** %4, i64* %5, i32 %28)
%30 = icmp eq i32 %29, -1
%31 = load i8*, i8** %4
%32 = call i32 @free(i8* %31)
store i8* null, i8** %4
br i1 %30, label %71, label %33
33: ; preds = %27
%34 = load i32, i32* @stdin
%35 = call i32 @getline(i8** %4, i64* %5, i32 %34)
%36 = load i8*, i8** %4
%37 = icmp eq i32 %35, -1
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @free(i8* %36)
store i8* null, i8** %4
br label %71
40: ; preds = %33
%41 = call double @strtod(i8* %36, i8** %3)
%42 = fcmp olt double %41, 0.000000e+00
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i8*, i8** %4
%45 = call i32 @free(i8* %44)
store i8* null, i8** %4
br label %71
46: ; preds = %40
%47 = load i8*, i8** %3
%48 = call double @strtod(i8* %47, i8** %3)
%49 = fcmp olt double %48, 0.000000e+00
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = call i32 @free(i8* %51)
store i8* null, i8** %4
br label %71
53: ; preds = %46
%54 = load i8*, i8** %3
%55 = call double @strtod(i8* %54, i8** %3)
%56 = fcmp olt double %55, 0.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i8*, i8** %4
%59 = call i32 @free(i8* %58)
store i8* null, i8** %4
br label %71
60: ; preds = %53
%61 = fadd double %41, %48
%62 = fptosi double %61 to i32
%63 = fdiv double %61, %10
%64 = fmul double %63, 1.000000e+02
%65 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %62, double %64)
%66 = fadd double %48, %55
%67 = fptosi double %66 to i32
%68 = fdiv double %66, %13
%69 = fmul double %68, 1.000000e+02
%70 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %67, double %69)
br label %73
71: ; preds = %27, %23, %57, %50, %43, %38
%72 = call i32 (...) @usage()
br label %73
73: ; preds = %71, %60, %21
%74 = phi i32 [ -1, %21 ], [ -1, %71 ], [ 0, %60 ]
ret i32 %74
}