#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__ geopm_crc32_str(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char const *, ...);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *usage = "%s string\n\n"
                      "    Returns the geopm_hash() of the input string.\n"
                      "    this is useful for determining the region name\n"
                      "    from the region_id printed in the trace.\n"
                      "    Note the mpi-runtime and epoch regions have\n"
                      "    special region IDs:\n"
                      "        mpi-runtime: 4611686018427387904\n"
                      "        epoch:  9223372036854775808\n\n";
  if (argc == 1 || strncmp("-h", argv[1], strlen("-h")) == 0 ||
      strncmp("--help", argv[1], strlen("--help")) == 0) {
    printf(usage, argv[0]);
  } else {
    printf("%llu\n", (unsigned long long)geopm_crc32_str(0, argv[1]));
  }
  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)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11d3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xfb6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xfa4(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11d3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
lea    0xf85(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xf73(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ea <main+0xaa>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    120a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %edi,%edi
call   1060 <geopm_crc32_str@plt>
mov    %rax,%rsi
lea    0xf3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
je     11ae <main+0x6e>
mov    0x8(%rbx),%r14
lea    0xfdc(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ae <main+0x6e>
mov    0x8(%rbx),%r14
lea    0xfba(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ae <main+0x6e>
mov    0x8(%rbx),%rsi
xor    %edi,%edi
call   1060 <geopm_crc32_str@plt>
lea    0xf95(%rip),%rdi
mov    %rax,%rsi
jmp    11b8 <main+0x78>
mov    (%rbx),%rsi
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [308 x i8] c"%s string\0A\0A Returns the geopm_hash() of the input string.\0A this is useful for determining the region name\0A from the region_id printed in the trace.\0A Note the mpi-runtime and epoch regions have\0A special region IDs:\0A mpi-runtime: 4611686018427387904\0A epoch: 9223372036854775808\0A\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([308 x i8], [308 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %23, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = call i64 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %16, %9, %2
%24 = load i8*, i8** %6
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* %24, i8* %27)
br label %35
29: ; preds = %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @geopm_crc32_str(i32 0, i8* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %33)
br label %35
35: ; preds = %29, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [308 x i8] c"%s string\0A\0A Returns the geopm_hash() of the input string.\0A this is useful for determining the region name\0A from the region_id printed in the trace.\0A Note the mpi-runtime and epoch regions have\0A special region IDs:\0A mpi-runtime: 4611686018427387904\0A epoch: 9223372036854775808\0A\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = load i8*, i8** %5
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i64 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %11, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10, %4, %2
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([308 x i8], [308 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %22
18: ; preds = %10
%19 = load i8*, i8** %5
%20 = tail call i64 @geopm_crc32_str(i32 0, i8* %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %18, %15
ret i32 0
}