#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 */
struct grid {
  int dummy;
};

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ initial_r_pentomino(struct grid *, int, int, int, int);
int /*<<< orphan*/ initial_random(struct grid *, int, int, int, int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int process_arguments(int argc, char *argv[], struct grid *grid, int *step_size,
                      int *num_threads) {
  int opt, initialized = 0;
  *step_size = 1;
  *num_threads = 1;
  while ((opt = getopt(argc, argv, "t:s:i:h")) != -1) {
    switch (opt) {
    case 't':
      *num_threads = atoi(optarg);
      break;
    case 's':
      *step_size = atoi(optarg);
      break;
    case 'i':
      if (!strcmp(optarg, "rand"))
        break;
      if (!strcmp(optarg, "pent")) {
        initialized = 1;
        initial_r_pentomino(grid, -15, -15, 15, 15);
        break;
      }
    case 'h':
    default:
      fprintf(stderr,
              "%s [-t threads] [-s stepsize] "
              "[-i rand|pent]\n",
              argv[0]);
      return 0;
    }
  }
  if (!initialized)
    initial_random(grid, -1000, -1000, 1000, 1000);
  return 1;
}


x86 assembly (clang, -O0):
<process_arguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe90(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     12b1 <process_arguments+0x151>
mov    -0x2c(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0xc,%eax
ja     1284 <process_arguments+0x124>
mov    -0x38(%rbp),%rax
lea    0xe2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
jmp    12ac <process_arguments+0x14c>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12ac <process_arguments+0x14c>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1237 <process_arguments+0xd7>
jmp    12ac <process_arguments+0x14c>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    127a <process_arguments+0x11a>
movl   $0x1,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0xfffffff1,%edx
mov    $0xf,%r8d
mov    %edx,%esi
mov    %r8d,%ecx
call   1060 <initial_r_pentomino@plt>
jmp    12ac <process_arguments+0x14c>
jmp    127f <process_arguments+0x11f>
jmp    1284 <process_arguments+0x124>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdab(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12db <process_arguments+0x17b>
jmp    1196 <process_arguments+0x36>
cmpl   $0x0,-0x30(%rbp)
jne    12d4 <process_arguments+0x174>
mov    -0x18(%rbp),%rdi
mov    $0xfffffc18,%edx
mov    $0x3e8,%r8d
mov    %edx,%esi
mov    %r8d,%ecx
call   1050 <initial_random@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_arguments>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x1,(%rcx)
movl   $0x1,(%r8)
mov    $0x1,%al
mov    %eax,0xc(%rsp)
lea    0xe68(%rip),%r13
mov    0x2e59(%rip),%r14
jmp    11bc <process_arguments+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
call   1080 <atoi@plt>
mov    %eax,(%r12)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <getopt@plt>
cmp    $0x72,%eax
jle    11f0 <process_arguments+0x90>
cmp    $0x73,%eax
je     11b0 <process_arguments+0x50>
cmp    $0x74,%eax
jne    1279 <process_arguments+0x119>
mov    (%r14),%edi
call   1080 <atoi@plt>
mov    %eax,(%r15)
jmp    11bc <process_arguments+0x5c>
nopl   0x0(%rax)
cmp    $0x69,%eax
jne    1247 <process_arguments+0xe7>
mov    (%r14),%edi
lea    0xe09(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bc <process_arguments+0x5c>
mov    (%r14),%edi
lea    0xdfb(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1279 <process_arguments+0x119>
mov    0x10(%rsp),%rdi
mov    $0xfffffff1,%esi
mov    $0xfffffff1,%edx
mov    $0xf,%ecx
mov    $0xf,%r8d
call   1060 <initial_r_pentomino@plt>
movl   $0x0,0xc(%rsp)
jmp    11bc <process_arguments+0x5c>
cmp    $0xffffffff,%eax
jne    1279 <process_arguments+0x119>
mov    $0x1,%ebx
testb  $0x1,0xc(%rsp)
je     1293 <process_arguments+0x133>
mov    0x10(%rsp),%rdi
mov    $0xfffffc18,%esi
mov    $0xfffffc18,%edx
mov    $0x3e8,%ecx
mov    $0x3e8,%r8d
call   1050 <initial_random@plt>
jmp    1293 <process_arguments+0x133>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd86(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.grid = type { i32 }
@.str = [8 x i8] c"t:s:i:h\00"
@optarg = global i32 0
@.str.1 = [5 x i8] c"rand\00"
@.str.2 = [5 x i8] c"pent\00"
@stderr = global i32 0
@.str.3 = [46 x i8] c"%s [-t threads] [-s stepsize] [-i rand|pent]\0A\00"
define i32 @process_arguments(i32 %0, i8** %1, %struct.grid* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca %struct.grid*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store %struct.grid* %2, %struct.grid** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 0, i32* %13
%14 = load i32*, i32** %10
store i32 1, i32* %14
%15 = load i32*, i32** %11
store i32 1, i32* %15
br label %16
16: ; preds = %51, %5
%17 = load i32, i32* %7
%18 = load i8**, i8*** %8
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %12
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %52
21: ; preds = %16
%22 = load i32, i32* %12
switch i32 %22, label %45 [
i32 116, label %23
i32 115, label %27
i32 105, label %31
i32 104, label %44
]
23: ; preds = %21
%24 = load i32, i32* @optarg
%25 = call i32 @atoi(i32 %24)
%26 = load i32*, i32** %11
store i32 %25, i32* %26
br label %51
27: ; preds = %21
%28 = load i32, i32* @optarg
%29 = call i32 @atoi(i32 %28)
%30 = load i32*, i32** %10
store i32 %29, i32* %30
br label %51
31: ; preds = %21
%32 = load i32, i32* @optarg
%33 = call i32 @strcmp(i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31
br label %51
36: ; preds = %31
%37 = load i32, i32* @optarg
%38 = call i32 @strcmp(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
store i32 1, i32* %13
%41 = load %struct.grid*, %struct.grid** %9
%42 = call i32 @initial_r_pentomino(%struct.grid* %41, i32 -15, i32 -15, i32 15, i32 15)
br label %51
43: ; preds = %36
br label %44
44: ; preds = %21, %43
br label %45
45: ; preds = %21, %44
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %8
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %49)
store i32 0, i32* %6
br label %59
51: ; preds = %40, %35, %27, %23
br label %16
52: ; preds = %16
%53 = load i32, i32* %13
%54 = icmp ne i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load %struct.grid*, %struct.grid** %9
%57 = call i32 @initial_random(%struct.grid* %56, i32 -1000, i32 -1000, i32 1000, i32 1000)
br label %58
58: ; preds = %55, %52
store i32 1, i32* %6
br label %59
59: ; preds = %58, %45
%60 = load i32, i32* %6
ret i32 %60
}

LLVM IR (-O2):
%struct.grid = type { i32 }
@.str = [8 x i8] c"t:s:i:h\00"
@optarg = global i32 0
@.str.1 = [5 x i8] c"rand\00"
@.str.2 = [5 x i8] c"pent\00"
@stderr = global i32 0
@.str.3 = [46 x i8] c"%s [-t threads] [-s stepsize] [-i rand|pent]\0A\00"
define i32 @process_arguments(i32 %0, i8** %1, %struct.grid* %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
store i32 1, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %25, %5
%7 = phi i1 [ false, %25 ], [ true, %5 ]
br label %8
8: ; preds = %20, %6
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %27 [
i32 -1, label %31
i32 116, label %10
i32 115, label %13
i32 105, label %16
]
10: ; preds = %8
%11 = load i32, i32* @optarg
%12 = tail call i32 @atoi(i32 %11)
store i32 %12, i32* %4
br label %20
13: ; preds = %8
%14 = load i32, i32* @optarg
%15 = tail call i32 @atoi(i32 %14)
store i32 %15, i32* %3
br label %20
16: ; preds = %8
%17 = load i32, i32* @optarg
%18 = tail call i32 @strcmp(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16, %13, %10
br label %8
21: ; preds = %16
%22 = load i32, i32* @optarg
%23 = tail call i32 @strcmp(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = tail call i32 @initial_r_pentomino(%struct.grid* %2, i32 -15, i32 -15, i32 15, i32 15)
br label %6
27: ; preds = %21, %8
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %34
31: ; preds = %8
br i1 %7, label %32, label %34
32: ; preds = %31
%33 = tail call i32 @initial_random(%struct.grid* %2, i32 -1000, i32 -1000, i32 1000, i32 1000)
br label %34
34: ; preds = %31, %32, %27
%35 = phi i32 [ 0, %27 ], [ 1, %32 ], [ 1, %31 ]
ret i32 %35
}