#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 EOF;
float atof(char *);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ find_peak(int, float, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int dump = 0, skip = 0;
  float perc = 0.9;
  int c;
  while ((c = getopt(argc, argv, "ds:")) != EOF)
    switch (c) {
    case 'd':
      dump = 1;
      break;
    case 's':
      skip = atoi(optarg);
      break;
    default:
      usage(*argv);
    }
  switch (argc - optind) {
  case 0:
    break;
  case 1:
    if (dump)
      usage(*argv);
    perc = atof(argv[optind]);
    break;
  default:
    usage(*argv);
  }
  find_peak(skip, perc, dump);
  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)
movss  0xe84(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%eax
je     11fe <main+0xae>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x64,%eax
je     11cb <main+0x7b>
jmp    11ba <main+0x6a>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
je     11d7 <main+0x87>
jmp    11ed <main+0x9d>
movl   $0x1,-0x14(%rbp)
jmp    11f9 <main+0xa9>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11f9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
jmp    1181 <main+0x31>
mov    -0x8(%rbp),%eax
mov    0x2dd0(%rip),%rcx
mov    (%rcx),%ecx
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
je     122b <main+0xdb>
jmp    121a <main+0xca>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     1230 <main+0xe0>
jmp    1267 <main+0x117>
jmp    1273 <main+0x123>
cmpl   $0x0,-0x14(%rbp)
je     1246 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d87(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x1c(%rbp)
jmp    1273 <main+0x123>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x18(%rbp),%edi
movss  -0x1c(%rbp),%xmm0
mov    -0x14(%rbp),%esi
call   1030 <find_peak@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9d(%rip),%rdx
call   1060 <getopt@plt>
mov    0x2e6d(%rip),%r13
xor    %r15d,%r15d
mov    $0x0,%r14d
cmp    0x0(%r13),%eax
jne    11c0 <main+0x70>
mov    0x2e4f(%rip),%r12
mov    (%r12),%eax
movss  0xe6b(%rip),%xmm0
sub    %eax,%ebp
je     1228 <main+0xd8>
cmp    $0x1,%ebp
jne    1218 <main+0xc8>
test   %r14d,%r14d
je     11b3 <main+0x63>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    (%r12),%eax
cltq
mov    (%rbx,%rax,8),%rdi
call   1040 <atof@plt>
jmp    1228 <main+0xd8>
xor    %r14d,%r14d
lea    0xe3a(%rip),%r12
xor    %r15d,%r15d
jmp    11eb <main+0x9b>
nop
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <getopt@plt>
cmp    0x0(%r13),%eax
je     1182 <main+0x32>
cmp    $0x64,%eax
je     1210 <main+0xc0>
cmp    $0x73,%eax
jne    11d0 <main+0x80>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,%r15d
jmp    11d8 <main+0x88>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r14d
jmp    11d8 <main+0x88>
mov    (%rbx),%rdi
call   1050 <usage@plt>
movss  0xdd8(%rip),%xmm0
mov    %r15d,%edi
mov    %r14d,%esi
call   1030 <find_peak@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ds:\00"
@EOF = global i32 0
@optarg = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = 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 float 0x3FECCCCCC0000000, float* %8
br label %10
10: ; preds = %26, %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 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %10
%17 = load i32, i32* %9
switch i32 %17, label %22 [
i32 100, label %18
i32 115, label %19
]
18: ; preds = %16
store i32 1, i32* %6
br label %26
19: ; preds = %16
%20 = load i32, i32* @optarg
%21 = call i32 @atoi(i32 %20)
store i32 %21, i32* %7
br label %26
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = call i32 @usage(i8* %24)
br label %26
26: ; preds = %22, %19, %18
br label %10
27: ; preds = %10
%28 = load i32, i32* %4
%29 = load i32, i32* @optind
%30 = sub nsw i32 %28, %29
switch i32 %30, label %46 [
i32 0, label %31
i32 1, label %32
]
31: ; preds = %27
br label %50
32: ; preds = %27
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = load i8*, i8** %36
%38 = call i32 @usage(i8* %37)
br label %39
39: ; preds = %35, %32
%40 = load i8**, i8*** %5
%41 = load i32, i32* @optind
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call float @atof(i8* %44)
store float %45, float* %8
br label %50
46: ; preds = %27
%47 = load i8**, i8*** %5
%48 = load i8*, i8** %47
%49 = call i32 @usage(i8* %48)
br label %50
50: ; preds = %46, %39, %31
%51 = load i32, i32* %7
%52 = load float, float* %8
%53 = load i32, i32* %6
%54 = call i32 @find_peak(i32 %51, float %52, i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"ds:\00"
@EOF = global i32 0
@optarg = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %22, label %6
6: ; preds = %2, %16
%7 = phi i32 [ %19, %16 ], [ %3, %2 ]
%8 = phi i32 [ %18, %16 ], [ 0, %2 ]
%9 = phi i32 [ %17, %16 ], [ 0, %2 ]
switch i32 %7, label %13 [
i32 100, label %16
i32 115, label %10
]
10: ; preds = %6
%11 = load i32, i32* @optarg
%12 = tail call i32 @atoi(i32 %11)
br label %16
13: ; preds = %6
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i8* %14)
br label %16
16: ; preds = %6, %13, %10
%17 = phi i32 [ %9, %13 ], [ %12, %10 ], [ %9, %6 ]
%18 = phi i32 [ %8, %13 ], [ %8, %10 ], [ 1, %6 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %6
22: ; preds = %16, %2
%23 = phi i32 [ 0, %2 ], [ %17, %16 ]
%24 = phi i32 [ 0, %2 ], [ %18, %16 ]
%25 = load i32, i32* @optind
%26 = sub nsw i32 %0, %25
switch i32 %26, label %39 [
i32 0, label %42
i32 1, label %27
]
27: ; preds = %22
%28 = icmp eq i32 %24, 0
br i1 %28, label %33, label %29
29: ; preds = %27
%30 = load i8*, i8** %1
%31 = tail call i32 @usage(i8* %30)
%32 = load i32, i32* @optind
br label %33
33: ; preds = %29, %27
%34 = phi i32 [ %32, %29 ], [ %25, %27 ]
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call float @atof(i8* %37)
br label %42
39: ; preds = %22
%40 = load i8*, i8** %1
%41 = tail call i32 @usage(i8* %40)
br label %42
42: ; preds = %39, %33, %22
%43 = phi float [ 0x3FECCCCCC0000000, %39 ], [ %38, %33 ], [ 0x3FECCCCCC0000000, %22 ]
%44 = tail call i32 @find_peak(i32 %23, float %43, i32 %24)
ret i32 0
}