#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*/ display_help();
scalar_t__ is_perfect_number(unsigned long);
int /*<<< orphan*/ lookup_perfect_numbers(unsigned long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned long strtoul(char *, char **, int);
void parse_arguments(int argc, char *argv[]) {
  unsigned long int number;
  char *ptr;
  if (argc == 1) {
    display_help();
  } else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
    display_help();
  } else if (!strcmp(argv[1], "-c") && argc == 3) {
    number = strtoul(argv[2], &ptr, 10);
    (is_perfect_number(number)) ? printf("true\r\n") : printf("false\r\n");
  } else if (!strcmp(argv[1], "-r") && argc == 3) {
    number = strtoul(argv[2], &ptr, 10);
    lookup_perfect_numbers(number);
  }
}


x86 assembly (clang, -O0):
<parse_arguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1185 <parse_arguments+0x25>
mov    $0x0,%al
call   1060 <display_help@plt>
jmp    129a <parse_arguments+0x13a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     11bf <parse_arguments+0x5f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11cb <parse_arguments+0x6b>
mov    $0x0,%al
call   1060 <display_help@plt>
jmp    1295 <parse_arguments+0x135>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe30(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1241 <parse_arguments+0xe1>
cmpl   $0x3,-0x4(%rbp)
jne    1241 <parse_arguments+0xe1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <is_perfect_number@plt>
cmp    $0x0,%rax
je     1230 <parse_arguments+0xd0>
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
jmp    123c <parse_arguments+0xdc>
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
jmp    1290 <parse_arguments+0x130>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    128b <parse_arguments+0x12b>
cmpl   $0x3,-0x4(%rbp)
jne    128b <parse_arguments+0x12b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <lookup_perfect_numbers@plt>
jmp    1290 <parse_arguments+0x130>
jmp    1295 <parse_arguments+0x135>
jmp    129a <parse_arguments+0x13a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_arguments>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
je     11dd <parse_arguments+0x7d>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11dd <parse_arguments+0x7d>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11dd <parse_arguments+0x7d>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
cmp    $0x3,%ebp
jne    11ec <parse_arguments+0x8c>
test   %eax,%eax
jne    11ec <parse_arguments+0x8c>
mov    0x10(%r14),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,%rdi
call   1040 <is_perfect_number@plt>
test   %rax,%rax
je     1230 <parse_arguments+0xd0>
lea    0xe3c(%rip),%rdi
jmp    1237 <parse_arguments+0xd7>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <display_help@plt>
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
cmp    $0x3,%ebp
jne    1227 <parse_arguments+0xc7>
test   %eax,%eax
jne    1227 <parse_arguments+0xc7>
mov    0x10(%r14),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <lookup_perfect_numbers@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdd9(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [7 x i8] c"true\0D\0A\00"
@.str.4 = [8 x i8] c"false\0D\0A\00"
@.str.5 = [3 x i8] c"-r\00"
define void @parse_arguments(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @display_help()
br label %67
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %17, %11
%24 = call i32 (...) @display_help()
br label %66
25: ; preds = %17
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %48, label %31
31: ; preds = %25
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 3
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i64 @strtoul(i8* %37, i8** %6, i32 10)
store i64 %38, i64* %5
%39 = load i64, i64* %5
%40 = call i64 @is_perfect_number(i64 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %34
%43 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %46
44: ; preds = %34
%45 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = phi i32 [ %43, %42 ], [ %45, %44 ]
br label %65
48: ; preds = %31, %25
%49 = load i8**, i8*** %4
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %64, label %54
54: ; preds = %48
%55 = load i32, i32* %3
%56 = icmp eq i32 %55, 3
br i1 %56, label %57, label %64
57: ; preds = %54
%58 = load i8**, i8*** %4
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = call i64 @strtoul(i8* %60, i8** %6, i32 10)
store i64 %61, i64* %5
%62 = load i64, i64* %5
%63 = call i32 @lookup_perfect_numbers(i64 %62)
br label %64
64: ; preds = %57, %54, %48
br label %65
65: ; preds = %64, %46
br label %66
66: ; preds = %65, %23
br label %67
67: ; preds = %66, %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.5 = [3 x i8] c"-r\00"
@str = [7 x i8] c"false\0D\00"
@str.6 = [6 x i8] c"true\0D\00"
define void @parse_arguments(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @display_help()
br label %42
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %8
%17 = tail call i32 (...) @display_help()
br label %42
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
%21 = icmp eq i32 %0, 3
%22 = and i1 %21, %20
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = call i64 @strtoul(i8* %25, i8** %3, i32 10)
%27 = tail call i64 @is_perfect_number(i64 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
br label %42
31: ; preds = %23
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %42
33: ; preds = %18
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
%36 = and i1 %21, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = load i8*, i8** %38
%40 = call i64 @strtoul(i8* %39, i8** %3, i32 10)
%41 = tail call i32 @lookup_perfect_numbers(i64 %40)
br label %42
42: ; preds = %16, %33, %37, %29, %31, %6
ret void
}