#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *, char *);
int parse_args(int argc, char **argv) {
  int opt;
  while ((opt = getopt(argc, argv, "ch")) != -1) {
    switch (opt) {
    case 'c':
      printf("%s:\n"
             "Controls:\n"
             "A:                 Render body info\n"
             "Keyboard arrows:   Move screen\n"
             "Mouse scroll:      Zoom in/out\n"
             "Left mouse btn:    Select a body\n"
             "Right mouse btn:   Create a body\n"
             "Enter:             Reset zoom\n"
             "ESQ:               Quit program\n",
             argv[0]);
      exit(EXIT_SUCCESS);
    default:
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     119c <parse_args+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x63,%eax
jne    1190 <parse_args+0x60>
jmp    116f <parse_args+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <parse_args+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbx
mov    %rsi,%rbx
lea    0xec5(%rip),%rdx
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     1153 <parse_args+0x23>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x63,%ecx
je     1157 <parse_args+0x27>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"ch\00"
@.str.1 = [241 x i8] c"%s:\0AControls:\0AA: Render body info\0AKeyboard arrows: Move screen\0AMouse scroll: Zoom in/out\0ALeft mouse btn: Select a body\0ARight mouse btn: Create a body\0AEnter: Reset zoom\0AESQ: Quit program\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @parse_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %21 [
i32 99, label %14
]
14: ; preds = %12
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([241 x i8], [241 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
store i32 -1, i32* %3
br label %23
22: ; preds = %7
store i32 0, i32* %3
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [3 x i8] c"ch\00"
@.str.1 = [241 x i8] c"%s:\0AControls:\0AA: Render body info\0AKeyboard arrows: Move screen\0AMouse scroll: Zoom in/out\0ALeft mouse btn: Select a body\0ARight mouse btn: Create a body\0AEnter: Reset zoom\0AESQ: Quit program\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @parse_args(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %3, label %10 [
i32 -1, label %9
i32 99, label %4
]
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([241 x i8], [241 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @EXIT_SUCCESS
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
br label %10
10: ; preds = %2, %9
%11 = phi i32 [ 0, %9 ], [ -1, %2 ]
ret i32 %11
}