#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 atoi(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ print_version();
int process_options(int argc, char **argv, int *num_mines, int *h, int *w) {
  int opt = 0;
  while ((opt = getopt(argc, argv, "hvn:x:y:")) != -1) {
    switch (opt) {
    case 'h':
      print_help();
      return 1;
      break;
    case 'v':
      print_version();
      return 1;
      break;
    case 'n':
      *num_mines = atoi(optarg);
      if (*num_mines == 0)
        *num_mines = 10;
      break;
    case 'x':
      *w = atoi(optarg);
      if (*w == 0)
        *w = 10;
      break;
    case 'y':
      *h = atoi(optarg);
      if (*h == 0)
        *h = 10;
      break;
    default:
      print_help();
      return 1;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<process_options>:
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,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed8(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     127e <process_options+0x13e>
mov    -0x2c(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x11,%eax
ja     1266 <process_options+0x126>
mov    -0x38(%rbp),%rax
lea    0xe5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <process_options+0x145>
mov    $0x0,%al
call   1030 <print_version@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <process_options+0x145>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11fd <process_options+0xbd>
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
jmp    1279 <process_options+0x139>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    122f <process_options+0xef>
mov    -0x28(%rbp),%rax
movl   $0xa,(%rax)
jmp    1279 <process_options+0x139>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1261 <process_options+0x121>
mov    -0x20(%rbp),%rax
movl   $0xa,(%rax)
jmp    1279 <process_options+0x139>
mov    $0x0,%al
call   1060 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <process_options+0x145>
jmp    1162 <process_options+0x22>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xee1(%rip),%r13
lea    0xe92(%rip),%r14
jmp    1191 <process_options+0x51>
mov    0x10(%rsp),%r12
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1050 <atoi@plt>
test   %eax,%eax
mov    $0xa,%ecx
cmove  %ecx,%eax
mov    %eax,(%r12)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1040 <getopt@plt>
lea    -0x68(%rax),%ecx
cmp    $0x11,%ecx
ja     11b9 <process_options+0x79>
movslq (%r14,%rcx,4),%rax
add    %r14,%rax
mov    %r15,%r12
jmp    *%rax
mov    0x8(%rsp),%r12
jmp    1175 <process_options+0x35>
cmp    $0xffffffff,%eax
jne    11c2 <process_options+0x82>
xor    %eax,%eax
jmp    11d7 <process_options+0x97>
xor    %eax,%eax
call   1060 <print_help@plt>
jmp    11d2 <process_options+0x92>
xor    %eax,%eax
call   1030 <print_version@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"hvn:x:y:\00"
@optarg = global i32 0
define i32 @process_options(i32 %0, i8** %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 0, i32* %12
br label %13
13: ; preds = %56, %5
%14 = load i32, i32* %7
%15 = load i8**, i8*** %8
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %12
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %57
18: ; preds = %13
%19 = load i32, i32* %12
switch i32 %19, label %54 [
i32 104, label %20
i32 118, label %22
i32 110, label %24
i32 120, label %34
i32 121, label %44
]
20: ; preds = %18
%21 = call i32 (...) @print_help()
store i32 1, i32* %6
br label %58
22: ; preds = %18
%23 = call i32 (...) @print_version()
store i32 1, i32* %6
br label %58
24: ; preds = %18
%25 = load i32, i32* @optarg
%26 = call i32 @atoi(i32 %25)
%27 = load i32*, i32** %9
store i32 %26, i32* %27
%28 = load i32*, i32** %9
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load i32*, i32** %9
store i32 10, i32* %32
br label %33
33: ; preds = %31, %24
br label %56
34: ; preds = %18
%35 = load i32, i32* @optarg
%36 = call i32 @atoi(i32 %35)
%37 = load i32*, i32** %11
store i32 %36, i32* %37
%38 = load i32*, i32** %11
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = load i32*, i32** %11
store i32 10, i32* %42
br label %43
43: ; preds = %41, %34
br label %56
44: ; preds = %18
%45 = load i32, i32* @optarg
%46 = call i32 @atoi(i32 %45)
%47 = load i32*, i32** %10
store i32 %46, i32* %47
%48 = load i32*, i32** %10
%49 = load i32, i32* %48
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %44
%52 = load i32*, i32** %10
store i32 10, i32* %52
br label %53
53: ; preds = %51, %44
br label %56
54: ; preds = %18
%55 = call i32 (...) @print_help()
store i32 1, i32* %6
br label %58
56: ; preds = %53, %43, %33
br label %13
57: ; preds = %13
store i32 0, i32* %6
br label %58
58: ; preds = %57, %54, %22, %20
%59 = load i32, i32* %6
ret i32 %59
}

LLVM IR (-O2):
@.str = [9 x i8] c"hvn:x:y:\00"
@optarg = global i32 0
define i32 @process_options(i32 %0, i8** %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
br label %6
6: ; preds = %16, %5
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %14 [
i32 -1, label %22
i32 104, label %8
i32 118, label %10
i32 110, label %16
i32 120, label %12
i32 121, label %13
]
8: ; preds = %6
%9 = tail call i32 (...) @print_help()
br label %22
10: ; preds = %6
%11 = tail call i32 (...) @print_version()
br label %22
12: ; preds = %6
br label %16
13: ; preds = %6
br label %16
14: ; preds = %6
%15 = tail call i32 (...) @print_help()
br label %22
16: ; preds = %6, %13, %12
%17 = phi i32* [ %3, %13 ], [ %4, %12 ], [ %2, %6 ]
%18 = load i32, i32* @optarg
%19 = tail call i32 @atoi(i32 %18)
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 10, i32 %19
store i32 %21, i32* %17
br label %6
22: ; preds = %6, %14, %10, %8
%23 = phi i32 [ 1, %14 ], [ 1, %10 ], [ 1, %8 ], [ 0, %6 ]
ret i32 %23
}