#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 atoi(int /*<<< orphan*/);
long atoll(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printhelp();
int /*<<< orphan*/ run_dhrystone(int, int, long, int);
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  int num_threads = 1;
  int runtime = 0;
  int delay = 0;
  long mloops = 0;
  int opt;
  while ((opt = getopt(argc, argv, "ht:r:d:l:")) != -1) {
    switch (opt) {
    case 'h':
      printhelp();
      exit(0);
      break;
    case 't':
      num_threads = atoi(optarg);
      break;
    case 'r':
      runtime = atoi(optarg);
      break;
    case 'd':
      delay = atoi(optarg);
      break;
    case 'l':
      mloops = atoll(optarg);
      break;
    }
  }
  if (runtime && mloops) {
    fprintf(stderr,
            "-r and -l options cannot be specified at the same time.\n");
    exit(1);
  } else if (!runtime && !mloops) {
    fprintf(stderr,
            "Must specify either -r or -l option; use -h to see help.\n");
    exit(1);
  }
  long num_loops = mloops ? mloops * 1000000L : 500000 * num_threads;
  run_dhrystone(runtime, num_threads, num_loops, delay);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1252 <main+0xe2>
mov    -0x2c(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x10,%eax
ja     124d <main+0xdd>
mov    -0x40(%rbp),%rax
lea    0xe1e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <printhelp@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    124d <main+0xdd>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    124d <main+0xdd>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    124d <main+0xdd>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1030 <atoll@plt>
mov    %rax,-0x28(%rbp)
jmp    11a3 <main+0x33>
cmpl   $0x0,-0x18(%rbp)
je     1286 <main+0x116>
cmpq   $0x0,-0x28(%rbp)
je     1286 <main+0x116>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12ba <main+0x14a>
cmpq   $0x0,-0x28(%rbp)
jne    12ba <main+0x14a>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    12bf <main+0x14f>
cmpq   $0x0,-0x28(%rbp)
je     12db <main+0x16b>
imul   $0xf4240,-0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12e8 <main+0x178>
imul   $0x7a120,-0x14(%rbp),%eax
cltq
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1050 <run_dhrystone@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%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,%ebp
lea    0xe9a(%rip),%rdx
call   1060 <getopt@plt>
cmp    $0xffffffff,%eax
je     1259 <main+0xe9>
xor    %ecx,%ecx
mov    %rcx,0x10(%rsp)
movl   $0x1,0xc(%rsp)
lea    0xe76(%rip),%r15
lea    0xe4b(%rip),%r14
mov    0x2e3c(%rip),%r12
xor    %r13d,%r13d
movl   $0x0,0x8(%rsp)
jmp    11e7 <main+0x77>
mov    (%r12),%edi
call   1030 <atoll@plt>
mov    %rax,%r13
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0xffffffff,%eax
je     1228 <main+0xb8>
add    $0xffffff9c,%eax
ror    %eax
cmp    $0x8,%eax
ja     11d5 <main+0x65>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    (%r12),%edi
call   1070 <atoi@plt>
mov    %eax,0x8(%rsp)
jmp    11d5 <main+0x65>
mov    (%r12),%edi
call   1070 <atoi@plt>
mov    %rax,0x10(%rsp)
jmp    11d5 <main+0x65>
mov    (%r12),%edi
call   1070 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    11d5 <main+0x65>
test   %r13,%r13
setne  %al
mov    0x10(%rsp),%rdi
test   %edi,%edi
setne  %dl
je     126f <main+0xff>
test   %r13,%r13
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
je     1269 <main+0xf9>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
jmp    12c9 <main+0x159>
xor    %eax,%eax
mov    $0x1,%esi
xor    %edx,%edx
xor    %edi,%edi
xor    %r13d,%r13d
xor    %ecx,%ecx
test   %dl,%dl
je     127b <main+0x10b>
jmp    127f <main+0x10f>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
test   %dl,%dl
jne    127f <main+0x10f>
test   %al,%al
je     12b9 <main+0x149>
imul   $0xf4240,%r13,%rbp
imul   $0x7a120,%esi,%edx
movslq %edx,%rdx
test   %al,%al
cmovne %rbp,%rdx
call   1050 <run_dhrystone@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1090 <printhelp@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"ht:r:d:l:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [57 x i8] c"-r and -l options cannot be specified at the same time.\0A\00"
@.str.2 = [58 x i8] c"Must specify either -r or -l option; use -h to see help.\0A\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 i64
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i64 0, i64* %9
br label %12
12: ; preds = %34, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %10
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %35
17: ; preds = %12
%18 = load i32, i32* %10
switch i32 %18, label %34 [
i32 104, label %19
i32 116, label %22
i32 114, label %25
i32 100, label %28
i32 108, label %31
]
19: ; preds = %17
%20 = call i32 (...) @printhelp()
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %17
%23 = load i32, i32* @optarg
%24 = call i32 @atoi(i32 %23)
store i32 %24, i32* %6
br label %34
25: ; preds = %17
%26 = load i32, i32* @optarg
%27 = call i32 @atoi(i32 %26)
store i32 %27, i32* %7
br label %34
28: ; preds = %17
%29 = load i32, i32* @optarg
%30 = call i32 @atoi(i32 %29)
store i32 %30, i32* %8
br label %34
31: ; preds = %17
%32 = load i32, i32* @optarg
%33 = call i64 @atoll(i32 %32)
store i64 %33, i64* %9
br label %34
34: ; preds = %17, %31, %28, %25, %22
br label %12
35: ; preds = %12
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i64, i64* %9
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %38, %35
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 0
br i1 %47, label %55, label %48
48: ; preds = %45
%49 = load i64, i64* %9
%50 = icmp ne i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %48, %45
br label %56
56: ; preds = %55
%57 = load i64, i64* %9
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i64, i64* %9
%61 = mul nsw i64 %60, 1000000
br label %66
62: ; preds = %56
%63 = load i32, i32* %6
%64 = mul nsw i32 500000, %63
%65 = sext i32 %64 to i64
br label %66
66: ; preds = %62, %59
%67 = phi i64 [ %61, %59 ], [ %65, %62 ]
store i64 %67, i64* %11
%68 = load i32, i32* %7
%69 = load i32, i32* %6
%70 = load i64, i64* %11
%71 = load i32, i32* %8
%72 = call i32 @run_dhrystone(i32 %68, i32 %69, i64 %70, i32 %71)
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [10 x i8] c"ht:r:d:l:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [57 x i8] c"-r and -l options cannot be specified at the same time.\0A\00"
@.str.2 = [58 x i8] c"Must specify either -r or -l option; use -h to see help.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %43, label %5
5: ; preds = %2, %28
%6 = phi i32 [ %33, %28 ], [ %3, %2 ]
%7 = phi i32 [ %32, %28 ], [ 1, %2 ]
%8 = phi i32 [ %31, %28 ], [ 0, %2 ]
%9 = phi i64 [ %30, %28 ], [ 0, %2 ]
%10 = phi i32 [ %29, %28 ], [ 0, %2 ]
%11 = add i32 %6, -100
%12 = tail call i32 @llvm.fshl.i32(i32 %11, i32 %11, i32 31)
switch i32 %12, label %28 [
i32 2, label %13
i32 8, label %16
i32 7, label %19
i32 0, label %22
i32 4, label %25
]
13: ; preds = %5
%14 = tail call i32 (...) @printhelp()
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %5
%17 = load i32, i32* @optarg
%18 = tail call i32 @atoi(i32 %17)
br label %28
19: ; preds = %5
%20 = load i32, i32* @optarg
%21 = tail call i32 @atoi(i32 %20)
br label %28
22: ; preds = %5
%23 = load i32, i32* @optarg
%24 = tail call i32 @atoi(i32 %23)
br label %28
25: ; preds = %5
%26 = load i32, i32* @optarg
%27 = tail call i64 @atoll(i32 %26)
br label %28
28: ; preds = %5, %25, %22, %19, %16
%29 = phi i32 [ %10, %5 ], [ %10, %25 ], [ %24, %22 ], [ %10, %19 ], [ %10, %16 ]
%30 = phi i64 [ %9, %5 ], [ %27, %25 ], [ %9, %22 ], [ %9, %19 ], [ %9, %16 ]
%31 = phi i32 [ %8, %5 ], [ %8, %25 ], [ %8, %22 ], [ %21, %19 ], [ %8, %16 ]
%32 = phi i32 [ %7, %5 ], [ %7, %25 ], [ %7, %22 ], [ %7, %19 ], [ %18, %16 ]
%33 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %5
35: ; preds = %28
%36 = icmp ne i32 %31, 0
%37 = icmp ne i64 %30, 0
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %2, %35
%44 = phi i1 [ %37, %35 ], [ false, %2 ]
%45 = phi i1 [ %36, %35 ], [ false, %2 ]
%46 = phi i32 [ %32, %35 ], [ 1, %2 ]
%47 = phi i32 [ %31, %35 ], [ 0, %2 ]
%48 = phi i64 [ %30, %35 ], [ 0, %2 ]
%49 = phi i32 [ %29, %35 ], [ 0, %2 ]
%50 = select i1 %45, i1 true, i1 %44
br i1 %50, label %55, label %51
51: ; preds = %43
%52 = load i32, i32* @stderr
%53 = tail call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%54 = tail call i32 @exit(i32 1)
unreachable
55: ; preds = %43
%56 = mul nsw i64 %48, 1000000
%57 = mul nsw i32 %46, 500000
%58 = sext i32 %57 to i64
%59 = select i1 %44, i64 %56, i64 %58
%60 = tail call i32 @run_dhrystone(i32 %47, i32 %46, i64 %59, i32 %49)
ret i32 0
}