#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 EOF;
scalar_t__ atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ hash(char *, unsigned int);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  unsigned int md = 60 * 24;
  char buf[128];
  int c;
  while ((c = getopt(argc, argv, "m:")) != EOF)
    switch (c) {
    case 'm':
      md = (unsigned int)atoi(optarg);
      break;
    default:
      break;
    }
  if (optind < argc) {
    while (optind < argc) {
      printf("%lu\n", hash(argv[optind++], md));
    }
  } else {
    srand((unsigned int)time(NULL));
    sprintf(buf, "%d", rand());
    printf("%lu\n", hash(buf, md));
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5a0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe42(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0xa4(%rbp)
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
je     120c <main+0x7c>
mov    -0xa4(%rbp),%eax
sub    $0x6d,%eax
jne    1202 <main+0x72>
jmp    11ec <main+0x5c>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1207 <main+0x77>
jmp    1207 <main+0x77>
jmp    11b0 <main+0x20>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1277 <main+0xe7>
jmp    1223 <main+0x93>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1272 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x2d98(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d8a(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x14(%rbp),%esi
call   1030 <hash@plt>
mov    %eax,%esi
lea    0xd9b(%rip),%rdi
call   1040 <printf@plt>
jmp    1223 <main+0x93>
jmp    12ce <main+0x13e>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%edx
lea    0xd5c(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <hash@plt>
mov    %eax,%esi
lea    0xd3a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xe53(%rip),%rdx
call   1070 <getopt@plt>
mov    0x2e27(%rip),%r12
mov    $0x5a0,%r14d
cmp    (%r12),%eax
jne    120b <main+0x7b>
mov    0x2e0c(%rip),%rbx
mov    (%rbx),%eax
cmp    %ebp,%eax
jge    1254 <main+0xc4>
lea    0xe26(%rip),%r15
nopl   (%rax)
lea    0x1(%rax),%ecx
mov    %ecx,(%rbx)
cltq
mov    0x0(%r13,%rax,8),%rdi
mov    %r14d,%esi
call   1030 <hash@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    (%rbx),%eax
cmp    %ebp,%eax
jl     11e0 <main+0x50>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    $0x5a0,%r14d
mov    0x2de0(%rip),%rbx
lea    0xde1(%rip),%r15
jmp    1243 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    (%r12),%eax
je     11c5 <main+0x35>
cmp    $0x6d,%eax
jne    1230 <main+0xa0>
mov    (%rbx),%edi
call   1080 <atoi@plt>
mov    %rax,%r14
jmp    1230 <main+0xa0>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
lea    0xd98(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <hash@plt>
lea    0xd74(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"m:\00"
@EOF = global i32 0
@optarg = global i32 0
@optind = global i32 0
@.str.1 = [5 x i8] c"%lu\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1440, i32* %6
br label %9
9: ; preds = %22, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %8
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %9
%16 = load i32, i32* %8
switch i32 %16, label %21 [
i32 109, label %17
]
17: ; preds = %15
%18 = load i32, i32* @optarg
%19 = call i64 @atoi(i32 %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %6
br label %22
21: ; preds = %15
br label %22
22: ; preds = %21, %17
br label %9
23: ; preds = %9
%24 = load i32, i32* @optind
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %43
27: ; preds = %23
br label %28
28: ; preds = %32, %27
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = load i32, i32* @optind
%35 = add nsw i32 %34, 1
store i32 %35, i32* @optind
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = load i32, i32* %6
%40 = call i32 @hash(i8* %38, i32 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %28
42: ; preds = %28
br label %54
43: ; preds = %23
%44 = call i64 @time(i32* null)
%45 = trunc i64 %44 to i32
%46 = call i32 @srand(i32 %45)
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%48 = call i32 (...) @rand()
%49 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%51 = load i32, i32* %6
%52 = call i32 @hash(i8* %50, i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %43, %42
%55 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"m:\00"
@EOF = global i32 0
@optarg = global i32 0
@optind = global i32 0
@.str.1 = [5 x i8] c"%lu\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %21, label %8
8: ; preds = %2, %16
%9 = phi i32 [ %18, %16 ], [ %5, %2 ]
%10 = phi i32 [ %17, %16 ], [ 1440, %2 ]
%11 = icmp eq i32 %9, 109
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @optarg
%14 = tail call i64 @atoi(i32 %13)
%15 = trunc i64 %14 to i32
br label %16
16: ; preds = %8, %12
%17 = phi i32 [ %15, %12 ], [ %10, %8 ]
%18 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %8
21: ; preds = %16, %2
%22 = phi i32 [ 1440, %2 ], [ %17, %16 ]
%23 = load i32, i32* @optind
%24 = icmp slt i32 %23, %0
br i1 %24, label %25, label %35
25: ; preds = %21, %25
%26 = phi i32 [ %33, %25 ], [ %23, %21 ]
%27 = add nsw i32 %26, 1
store i32 %27, i32* @optind
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 @hash(i8* %30, i32 %22)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @optind
%34 = icmp slt i32 %33, %0
br i1 %34, label %25, label %43
35: ; preds = %21
%36 = tail call i64 @time(i32* null)
%37 = trunc i64 %36 to i32
%38 = tail call i32 @srand(i32 %37)
%39 = tail call i32 (...) @rand()
%40 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = call i32 @hash(i8* %4, i32 %22)
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %25, %35
%44 = call i32 @exit(i32 0)
unreachable
}