#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 /*<<< orphan*/ RandomAccess_LCG(unsigned long, int, char *, double *,
                                    int *);
unsigned long atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_help_msg();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  unsigned long totalMemSize = 0;
  char *outFileName = "gupsout";
  double GUPS;
  int faillure;
  if (argc != 2 && argc != 3) {
    fprintf(stderr, "Error: invalid input parameters\n");
    print_help_msg();
    exit(-8);
  }
  totalMemSize = atoi(argv[1]);
  totalMemSize <<= 20;
  printf("$$ Get total memory size:%lu MB\n", totalMemSize >> 20);
  if (argc == 3) {
    outFileName = argv[2];
    printf("$$ Get Out File Name:%s\n", outFileName);
  }
  RandomAccess_LCG(totalMemSize, 1, outFileName, &GUPS, &faillure);
  if (!faillure) {
    printf("$$ Run RandomAccess Successfully, GUPS=%.6f\n", GUPS);
  } else {
    fprintf(stderr, "## Run RandomAccess Failed\n");
  }
}


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   $0x0,-0x18(%rbp)
lea    0xe7b(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c3 <main+0x63>
cmpl   $0x3,-0x8(%rbp)
je     11c3 <main+0x63>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <print_help_msg@plt>
mov    $0xfffffff8,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x14,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
shr    $0x14,%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jne    121e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x1,%esi
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1050 <RandomAccess_LCG@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    125a <main+0xfa>
movsd  -0x28(%rbp),%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    126f <main+0x10f>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1220 <main+0xc0>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %rax,%rbx
movabs $0xfffffffffff,%rsi
and    %rax,%rsi
shl    $0x14,%rbx
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%ebp
jne    11c2 <main+0x62>
mov    0x10(%r14),%rbp
lea    0xe94(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c9 <main+0x69>
lea    0xe37(%rip),%rbp
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
call   1050 <RandomAccess_LCG@plt>
cmpl   $0x0,0x4(%rsp)
je     1201 <main+0xa1>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1215 <main+0xb5>
movsd  0x8(%rsp),%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <print_help_msg@plt>
mov    $0xfffffff8,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"gupsout\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Error: invalid input parameters\0A\00"
@.str.2 = [33 x i8] c"$$ Get total memory size:%lu MB\0A\00"
@.str.3 = [25 x i8] c"$$ Get Out File Name:%s\0A\00"
@.str.4 = [45 x i8] c"$$ Run RandomAccess Successfully, GUPS=%.6f\0A\00"
@.str.5 = [28 x i8] c"## Run RandomAccess Failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (...) @print_help_msg()
%19 = call i32 @exit(i32 -8)
unreachable
20: ; preds = %12, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @atoi(i8* %23)
store i64 %24, i64* %6
%25 = load i64, i64* %6
%26 = shl i64 %25, 20
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = lshr i64 %27, 20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i64 %28)
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %38
32: ; preds = %20
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
store i8* %35, i8** %7
%36 = load i8*, i8** %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %32, %20
%39 = load i64, i64* %6
%40 = load i8*, i8** %7
%41 = call i32 @RandomAccess_LCG(i64 %39, i32 1, i8* %40, double* %8, i32* %9)
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = load double, double* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), double %45)
br label %50
47: ; preds = %38
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %47, %44
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [8 x i8] c"gupsout\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Error: invalid input parameters\0A\00"
@.str.2 = [33 x i8] c"$$ Get total memory size:%lu MB\0A\00"
@.str.3 = [25 x i8] c"$$ Get Out File Name:%s\0A\00"
@.str.4 = [45 x i8] c"$$ Run RandomAccess Successfully, GUPS=%.6f\0A\00"
@.str.5 = [28 x i8] c"## Run RandomAccess Failed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca i32
%5 = bitcast double* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = and i32 %0, -2
%8 = icmp eq i32 %7, 2
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 (...) @print_help_msg()
%13 = tail call i32 @exit(i32 -8)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @atoi(i8* %16)
%18 = shl i64 %17, 20
%19 = and i64 %17, 17592186044415
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i64 %19)
%21 = icmp eq i32 %0, 3
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %14
%27 = phi i8* [ %24, %22 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %14 ]
%28 = call i32 @RandomAccess_LCG(i64 %18, i32 1, i8* %27, double* %3, i32* %4)
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load double, double* %3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), double %32)
br label %37
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %34, %31
ret i32 0
}