#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 omp_sched_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int getopt(int, char **, char *);
int *make_array(long);
int /*<<< orphan*/ omp_get_schedule(int *, int *);
double omp_get_wtime();
int /*<<< orphan*/ omp_sched_print(int, int);
int omp_sched_static;
int /*<<< orphan*/ omp_set_schedule(int, int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ process(int);
void *strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  omp_sched_t omp_sched_kind = omp_sched_static;
  int omp_sched_modifier = 0;
  long array_size = 1000;
  int opt;
  while ((opt = getopt(argc, argv, "k:m:s:")) != -1) {
    switch (opt) {
    case 'k':
      omp_sched_kind = strtol(optarg, NULL, 10);
      break;
    case 'm':
      omp_sched_modifier = strtol(optarg, NULL, 10);
      break;
    case 's':
      array_size = strtol(optarg, NULL, 10);
      break;
    default:
      printf("usage: %s -k <omp_sched_kind> -m <omp_sched_modifier> -s "
             "<array_size>\n",
             argv[0]);
    }
  }
  int *array = make_array(array_size);
  if (array == NULL) {
    exit(EXIT_FAILURE);
  }
  omp_sched_print(omp_sched_kind, omp_sched_modifier);
  omp_set_schedule(omp_sched_kind, omp_sched_modifier);
  omp_sched_modifier = -1;
  omp_sched_kind = -1;
  double t = omp_get_wtime();
#pragma omp parallel
  {
#pragma omp single
    {
      omp_get_schedule(&omp_sched_kind, &omp_sched_modifier);
      omp_sched_print(omp_sched_kind, omp_sched_modifier);
    }
#pragma omp for schedule(runtime)
    for (int i = 0; i < array_size; i++) {
      process(array[i]);
    }
  }
  printf("%d %d %lf\n", omp_sched_kind, omp_sched_modifier,
         omp_get_wtime() - t);
  free(array);
  exit(EXIT_SUCCESS);
}


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)
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x3e8,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe11(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     12ae <main+0xfe>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x6b,%eax
je     1236 <main+0x86>
jmp    1214 <main+0x64>
mov    -0x40(%rbp),%eax
sub    $0x6d,%eax
je     1255 <main+0xa5>
jmp    1225 <main+0x75>
mov    -0x40(%rbp),%eax
sub    $0x73,%eax
je     1274 <main+0xc4>
jmp    1294 <main+0xe4>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    12a9 <main+0xf9>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,-0x18(%rbp)
jmp    12a9 <main+0xf9>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,-0x20(%rbp)
jmp    12a9 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    11e1 <main+0x31>
mov    -0x20(%rbp),%rdi
call   10d0 <make_array@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12d4 <main+0x124>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <omp_sched_print@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <omp_set_schedule@plt>
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    $0x0,%al
call   1050 <omp_get_wtime@plt>
movsd  %xmm0,-0x38(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <omp_get_schedule@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <omp_sched_print@plt>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    134f <main+0x19f>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1080 <process@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1323 <main+0x173>
mov    -0x14(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1050 <omp_get_wtime@plt>
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
subsd  -0x38(%rbp),%xmm0
lea    0xcda(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

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
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %rax,0x8(%rsp)
mov    $0x3e8,%r15d
lea    0xe22(%rip),%r13
mov    0x2e13(%rip),%r12
lea    0xe1b(%rip),%r14
xor    %eax,%eax
jmp    1200 <main+0x50>
mov    (%r12),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x10(%rsp)
jmp    1227 <main+0x77>
nopw   0x0(%rax,%rax,1)
cmp    $0x6b,%eax
je     1258 <main+0xa8>
cmp    $0xffffffff,%eax
je     126f <main+0xbf>
mov    (%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10b0 <getopt@plt>
cmp    $0x6c,%eax
jle    1210 <main+0x60>
cmp    $0x6d,%eax
je     11f0 <main+0x40>
cmp    $0x73,%eax
jne    121a <main+0x6a>
mov    (%r12),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%r15
jmp    1227 <main+0x77>
mov    (%r12),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,0x8(%rsp)
jmp    1227 <main+0x77>
mov    %r15,%rdi
call   10d0 <make_array@plt>
test   %rax,%rax
jne    128a <main+0xda>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rbp
mov    %ebp,%edi
mov    0x10(%rsp),%r14
mov    %r14d,%esi
call   1030 <omp_sched_print@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <omp_set_schedule@plt>
movl   $0xffffffff,(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
xor    %eax,%eax
call   1050 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   10a0 <omp_get_schedule@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1030 <omp_sched_print@plt>
test   %r15,%r15
jle    1301 <main+0x151>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%edi
call   1080 <process@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    12f0 <main+0x140>
mov    0x4(%rsp),%ebp
mov    (%rsp),%r14d
xor    %eax,%eax
call   1050 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xd31(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    $0x1,%al
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@omp_sched_static = global i32 0
@.str = [7 x i8] c"k:m:s:\00"
@optarg = global i32 0
@.str.1 = [71 x i8] c"usage: %s -k <omp_sched_kind> -m <omp_sched_modifier> -s <array_size>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"%d %d %lf\0A\00"
@EXIT_SUCCESS = 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 i64
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @omp_sched_static
store i32 %13, i32* %6
store i32 0, i32* %7
store i64 1000, i64* %8
br label %14
14: ; preds = %38, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %9
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = load i32, i32* %9
switch i32 %20, label %33 [
i32 107, label %21
i32 109, label %25
i32 115, label %29
]
21: ; preds = %19
%22 = load i32, i32* @optarg
%23 = call i8* @strtol(i32 %22, i32* null, i32 10)
%24 = ptrtoint i8* %23 to i32
store i32 %24, i32* %6
br label %38
25: ; preds = %19
%26 = load i32, i32* @optarg
%27 = call i8* @strtol(i32 %26, i32* null, i32 10)
%28 = ptrtoint i8* %27 to i32
store i32 %28, i32* %7
br label %38
29: ; preds = %19
%30 = load i32, i32* @optarg
%31 = call i8* @strtol(i32 %30, i32* null, i32 10)
%32 = ptrtoint i8* %31 to i64
store i64 %32, i64* %8
br label %38
33: ; preds = %19
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %33, %29, %25, %21
br label %14
39: ; preds = %14
%40 = load i64, i64* %8
%41 = call i32* @make_array(i64 %40)
store i32* %41, i32** %10
%42 = load i32*, i32** %10
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %39
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = call i32 @omp_sched_print(i32 %48, i32 %49)
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = call i32 @omp_set_schedule(i32 %51, i32 %52)
store i32 -1, i32* %7
store i32 -1, i32* %6
%54 = call double (...) @omp_get_wtime()
store double %54, double* %11
%55 = call i32 @omp_get_schedule(i32* %6, i32* %7)
%56 = load i32, i32* %6
%57 = load i32, i32* %7
%58 = call i32 @omp_sched_print(i32 %56, i32 %57)
store i32 0, i32* %12
br label %59
59: ; preds = %71, %47
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = load i64, i64* %8
%63 = icmp slt i64 %61, %62
br i1 %63, label %64, label %74
64: ; preds = %59
%65 = load i32*, i32** %10
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
%69 = load i32, i32* %68
%70 = call i32 @process(i32 %69)
br label %71
71: ; preds = %64
%72 = load i32, i32* %12
%73 = add nsw i32 %72, 1
store i32 %73, i32* %12
br label %59
74: ; preds = %59
%75 = load i32, i32* %6
%76 = load i32, i32* %7
%77 = call double (...) @omp_get_wtime()
%78 = load double, double* %11
%79 = fsub double %77, %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %75, i32 %76, double %79)
%81 = load i32*, i32** %10
%82 = call i32 @free(i32* %81)
%83 = load i32, i32* @EXIT_SUCCESS
%84 = call i32 @exit(i32 %83)
unreachable
}

LLVM IR (-O2):
@omp_sched_static = global i32 0
@.str = [7 x i8] c"k:m:s:\00"
@optarg = global i32 0
@.str.1 = [71 x i8] c"usage: %s -k <omp_sched_kind> -m <omp_sched_modifier> -s <array_size>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"%d %d %lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = load i32, i32* @omp_sched_static
%7 = bitcast i32* %4 to i8*
br label %8
8: ; preds = %19, %2
%9 = phi i32 [ %23, %19 ], [ %6, %2 ]
%10 = phi i32 [ %13, %19 ], [ 0, %2 ]
%11 = phi i64 [ %16, %19 ], [ 1000, %2 ]
br label %12
12: ; preds = %8, %24
%13 = phi i32 [ %10, %8 ], [ %28, %24 ]
%14 = phi i64 [ %11, %8 ], [ %16, %24 ]
br label %15
15: ; preds = %12, %29
%16 = phi i64 [ %14, %12 ], [ %32, %29 ]
br label %17
17: ; preds = %15, %33
%18 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %18, label %33 [
i32 -1, label %36
i32 107, label %19
i32 109, label %24
i32 115, label %29
]
19: ; preds = %17
%20 = load i32, i32* @optarg
%21 = tail call i8* @strtol(i32 %20, i32* null, i32 10)
%22 = ptrtoint i8* %21 to i64
%23 = trunc i64 %22 to i32
br label %8
24: ; preds = %17
%25 = load i32, i32* @optarg
%26 = tail call i8* @strtol(i32 %25, i32* null, i32 10)
%27 = ptrtoint i8* %26 to i64
%28 = trunc i64 %27 to i32
br label %12
29: ; preds = %17
%30 = load i32, i32* @optarg
%31 = tail call i8* @strtol(i32 %30, i32* null, i32 10)
%32 = ptrtoint i8* %31 to i64
br label %15
33: ; preds = %17
%34 = load i8*, i8** %1
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %17
36: ; preds = %17
%37 = tail call i32* @make_array(i64 %16)
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %36
%43 = tail call i32 @omp_sched_print(i32 %9, i32 %13)
%44 = tail call i32 @omp_set_schedule(i32 %9, i32 %13)
store i32 -1, i32* %4
store i32 -1, i32* %3
%45 = tail call double (...) @omp_get_wtime()
%46 = call i32 @omp_get_schedule(i32* %3, i32* %4)
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = call i32 @omp_sched_print(i32 %47, i32 %48)
%50 = icmp sgt i64 %16, 0
br i1 %50, label %60, label %51
51: ; preds = %60, %42
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call double (...) @omp_get_wtime()
%55 = fsub double %54, %45
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53, double %55)
%57 = call i32 @free(i32* %37)
%58 = load i32, i32* @EXIT_SUCCESS
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %42, %60
%61 = phi i64 [ %65, %60 ], [ 0, %42 ]
%62 = getelementptr inbounds i32, i32* %37, i64 %61
%63 = load i32, i32* %62
%64 = call i32 @process(i32 %63)
%65 = add nuw nsw i64 %61, 1
%66 = icmp eq i64 %65, %16
br i1 %66, label %51, label %60
}