#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 */
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int run_test(long, long, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
long strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  long runs = 5;
  long iters = 1024;
  int with_loop = 0;
  int fail = 0;
  if (argc > 4) {
    printf("%d is too many arguments.\n", argc - 1);
    fail = 1;
  }
  if (argc > 3) {
    iters = strtol(argv[3], NULL, 10);
    if ((errno) || (iters <= 0)) {
      printf("%s is not an in-range integer.\n", argv[3]);
      fail = 1;
    }
  }
  if (argc > 2) {
    runs = strtol(argv[2], NULL, 10);
    if ((errno) || (runs <= 0)) {
      printf("%s is not an in-range integer.\n", argv[2]);
      fail = 1;
    }
  }
  if (argc > 1) {
    if (strcmp(argv[1], "p") == 0) {
      with_loop = 2;
    } else if (strcmp(argv[1], "y") == 0) {
      with_loop = 1;
    } else if (strcmp(argv[1], "n") == 0) {
      with_loop = 0;
    } else {
      printf("%s is not in 'y', 'n', 'p'.\n", argv[1]);
      fail = 1;
    }
  }
  if (fail) {
    fprintf(stderr, "Usage: openmp_frequency [y|n] [5] [1024]\n");
    return 1;
  }
  return run_test(runs, iters, with_loop);
}


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)
movq   $0x5,-0x18(%rbp)
movq   $0x400,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    11a9 <main+0x59>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    120b <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e04(%rip),%rax
cmpq   $0x0,(%rax)
jne    11e9 <main+0x99>
cmpq   $0x0,-0x20(%rbp)
jg     1206 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    120b <main+0xbb>
cmpl   $0x2,-0x8(%rbp)
jle    126d <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2da2(%rip),%rax
cmpq   $0x0,(%rax)
jne    124b <main+0xfb>
cmpq   $0x0,-0x18(%rbp)
jg     1268 <main+0x118>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    126d <main+0x11d>
cmpl   $0x1,-0x8(%rbp)
jle    1321 <main+0x1d1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a1 <main+0x151>
movl   $0x2,-0x24(%rbp)
jmp    131c <main+0x1cc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12cb <main+0x17b>
movl   $0x1,-0x24(%rbp)
jmp    1317 <main+0x1c7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12f5 <main+0x1a5>
movl   $0x0,-0x24(%rbp)
jmp    1312 <main+0x1c2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    1317 <main+0x1c7>
jmp    131c <main+0x1cc>
jmp    1321 <main+0x1d1>
cmpl   $0x0,-0x28(%rbp)
je     134c <main+0x1fc>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    135f <main+0x20f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1070 <run_test@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%esi
cmp    $0x5,%edi
jl     1179 <main+0x29>
add    $0xffffffff,%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    1180 <main+0x30>
xor    %ebp,%ebp
cmp    $0x4,%esi
jne    11be <main+0x6e>
mov    0x18(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
mov    0x2e3e(%rip),%rax
cmpq   $0x0,(%rax)
jne    11a5 <main+0x55>
test   %r14,%r14
jg     11cf <main+0x7f>
mov    0x18(%rbx),%rsi
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11cf <main+0x7f>
mov    $0x400,%r14d
cmp    $0x3,%esi
jl     1274 <main+0x124>
xor    %ebp,%ebp
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r15
mov    0x2def(%rip),%rax
cmpq   $0x0,(%rax)
jne    11f4 <main+0xa4>
test   %r15,%r15
jg     120b <main+0xbb>
mov    0x10(%rbx),%rsi
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    0x8(%rbx),%rdi
lea    0xe25(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     125e <main+0x10e>
mov    0x8(%rbx),%rdi
lea    0xe12(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1269 <main+0x119>
mov    0x8(%rbx),%rdi
lea    0xdff(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1288 <main+0x138>
mov    0x8(%rbx),%rsi
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    128e <main+0x13e>
mov    $0x2,%edx
test   %ebp,%ebp
jne    128e <main+0x13e>
jmp    12b3 <main+0x163>
mov    $0x1,%edx
test   %ebp,%ebp
jne    128e <main+0x13e>
jmp    12b3 <main+0x163>
mov    $0x5,%r15d
xor    %ebp,%ebp
mov    $0x0,%edx
cmp    $0x2,%esi
je     120b <main+0xbb>
jmp    12b3 <main+0x163>
xor    %edx,%edx
test   %ebp,%ebp
je     12b3 <main+0x163>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <run_test@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"%d is too many arguments.\0A\00"
@errno = global i64 0
@.str.1 = [32 x i8] c"%s is not an in-range integer.\0A\00"
@.str.2 = [2 x i8] c"p\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"n\00"
@.str.5 = [29 x i8] c"%s is not in 'y', 'n', 'p'.\0A\00"
@stderr = global i32 0
@.str.6 = [42 x i8] c"Usage: openmp_frequency [y|n] [5] [1024]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 5, i64* %6
store i64 1024, i64* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 4
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 1, i32* %9
br label %16
16: ; preds = %12, %2
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 3
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @strtol(i8* %22, i32* null, i32 10)
store i64 %23, i64* %7
%24 = load i64, i64* @errno
%25 = icmp ne i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = load i64, i64* %7
%28 = icmp sle i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26, %19
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 1, i32* %9
br label %34
34: ; preds = %29, %26
br label %35
35: ; preds = %34, %16
%36 = load i32, i32* %4
%37 = icmp sgt i32 %36, 2
br i1 %37, label %38, label %54
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i64 @strtol(i8* %41, i32* null, i32 10)
store i64 %42, i64* %6
%43 = load i64, i64* @errno
%44 = icmp ne i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %38
%46 = load i64, i64* %6
%47 = icmp sle i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45, %38
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %51)
store i32 1, i32* %9
br label %53
53: ; preds = %48, %45
br label %54
54: ; preds = %53, %35
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 1
br i1 %56, label %57, label %86
57: ; preds = %54
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %57
store i32 2, i32* %8
br label %85
64: ; preds = %57
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %64
store i32 1, i32* %8
br label %84
71: ; preds = %64
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %71
store i32 0, i32* %8
br label %83
78: ; preds = %71
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %81)
store i32 1, i32* %9
br label %83
83: ; preds = %78, %77
br label %84
84: ; preds = %83, %70
br label %85
85: ; preds = %84, %63
br label %86
86: ; preds = %85, %54
%87 = load i32, i32* %9
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %97
92: ; preds = %86
%93 = load i64, i64* %6
%94 = load i64, i64* %7
%95 = load i32, i32* %8
%96 = call i32 @run_test(i64 %93, i64 %94, i32 %95)
store i32 %96, i32* %3
br label %97
97: ; preds = %92, %89
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str = [27 x i8] c"%d is too many arguments.\0A\00"
@errno = global i64 0
@.str.1 = [32 x i8] c"%s is not an in-range integer.\0A\00"
@.str.2 = [2 x i8] c"p\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"n\00"
@.str.5 = [29 x i8] c"%s is not in 'y', 'n', 'p'.\0A\00"
@stderr = global i32 0
@.str.6 = [42 x i8] c"Usage: openmp_frequency [y|n] [5] [1024]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = add nsw i32 %0, -1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %9
7: ; preds = %2
%8 = icmp eq i32 %0, 4
br i1 %8, label %9, label %21
9: ; preds = %4, %7
%10 = phi i32 [ 1, %4 ], [ 0, %7 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i64 @strtol(i8* nocapture %12, i32* null, i32 10)
%14 = load i64, i64* @errno
%15 = icmp ne i64 %14, 0
%16 = icmp slt i64 %13, 1
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = load i8*, i8** %11
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %23
21: ; preds = %7
%22 = icmp sgt i32 %0, 2
br i1 %22, label %23, label %36
23: ; preds = %9, %18, %21
%24 = phi i32 [ 0, %21 ], [ %10, %9 ], [ 1, %18 ]
%25 = phi i64 [ 1024, %21 ], [ %13, %9 ], [ %13, %18 ]
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i64 @strtol(i8* nocapture %27, i32* null, i32 10)
%29 = load i64, i64* @errno
%30 = icmp ne i64 %29, 0
%31 = icmp slt i64 %28, 1
%32 = select i1 %30, i1 true, i1 %31
br i1 %32, label %33, label %38
33: ; preds = %23
%34 = load i8*, i8** %26
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %38
36: ; preds = %21
%37 = icmp eq i32 %0, 2
br i1 %37, label %38, label %63
38: ; preds = %23, %33, %36
%39 = phi i32 [ 0, %36 ], [ %24, %23 ], [ 1, %33 ]
%40 = phi i64 [ 5, %36 ], [ %28, %23 ], [ %28, %33 ]
%41 = phi i64 [ 1024, %36 ], [ %25, %23 ], [ %25, %33 ]
%42 = getelementptr inbounds i8*, i8** %1, i64 1
%43 = load i8*, i8** %42
%44 = tail call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %57, label %46
46: ; preds = %38
%47 = load i8*, i8** %42
%48 = tail call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %57, label %50
50: ; preds = %46
%51 = load i8*, i8** %42
%52 = tail call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %50
%55 = load i8*, i8** %42
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %55)
br label %60
57: ; preds = %50, %46, %38
%58 = phi i32 [ 2, %38 ], [ 1, %46 ], [ 0, %50 ]
%59 = icmp eq i32 %39, 0
br i1 %59, label %63, label %60
60: ; preds = %54, %57
%61 = load i32, i32* @stderr
%62 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %68
63: ; preds = %36, %57
%64 = phi i32 [ %58, %57 ], [ 0, %36 ]
%65 = phi i64 [ %41, %57 ], [ 1024, %36 ]
%66 = phi i64 [ %40, %57 ], [ 5, %36 ]
%67 = tail call i32 @run_test(i64 %66, i64 %65, i32 %64)
br label %68
68: ; preds = %63, %60
%69 = phi i32 [ 1, %60 ], [ %67, %63 ]
ret i32 %69
}