// File: /workspace/github_cpp_makefile_star2_O3/TwilioDevEd[P]twilio_cpp_demo/src/cpp_demo.cc
// Function: main
int main(int argc, char * argv[])
{
        int cmd;
        std::string account_sid;
        std::string auth_token;
        std::string message;
        std::string from_number;
        std::string to_number;
        std::string picture_url;
        bool verbose = false;

        opterr = 0;

        while ((cmd = getopt(argc, argv, "a:s:m:f:t:p:vh?")) != -1) {
                switch (cmd) {
                        case '?':
                        case 'h':
                                printf("Twilio C++ Example Help:\n");
                                printf("-a: Account\t\t"
                                       "(ex: -a \"ACXXXXX\")\n");
                                printf("-s: Auth Token\t\t"
                                       "(ex: -s \"your_token\")\n");
                                printf("-f: From Number\t\t"
                                       "(ex: -f \"+18005551212\")\n");
                                printf("-t: To Number\t\t"
                                       "(ex: -t \"+18005551212\")\n");
                                printf("-m: Message to send\t"
                                       "(ex: -m \"Hello, Twilio!\")\n");
                                printf("-p: (Opt.) URL to Image\t"
                                       "(ex: -p \"Hello, Twilio!\")\n");
                                printf("-v: Verbose Mode\n");
                                printf("-h: This help dialog\n");
                                return 0;
                        case 'a':
                                account_sid = optarg;
                                break;
                        case 's':
                                auth_token = optarg;
                                break;
                        case 'm':
                                message = optarg;
                                break;
                        case 'f':
                                from_number = optarg;
                                break;
                        case 't':
                                to_number = optarg;
                                break;
                        case 'p':
                                picture_url = optarg;
                                break;
                        case 'v':
                                verbose = true;
                                break;
                        default:
                                abort();
                }
        }

        if ( account_sid.empty() or auth_token.empty() or from_number.empty()
                or to_number.empty() or message.empty() ) {
                std::cout<< "You didn't include all necessary inputs!\n"
                        "Call using -h for help.\n" << std::endl;
                return -1;
        }

        // Instantiate a twilio object and call send_message
        std::string response;
        auto twilio = std::make_shared<twilio::Twilio>(
            account_sid, 
            auth_token
        );
        
        bool message_success = twilio->send_message(
                to_number, 
                from_number, 
                message,
                response,
                picture_url,
                verbose
        );

        // Report success or failure
        if (!message_success) {
                if (verbose) {
                        std::cout << "Message send failed." << std::endl;
                        if (!response.empty()) {
                                std::cout << "Response:" << std::endl 
                                        << response << std::endl;
                        }
                }
                return -1;
        } else if (verbose) {
                std::cout << "SMS sent successfully!" << std::endl;
                std::cout << "Response:" << std::endl << response
                        << std::endl;
        }

        return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %edx, %edx
movq %rdx, -0x8(%rax)
movb %dl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rdx, -0x8(%rax)
movb %dl, (%rax)
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rdx, -0x8(%rax)
movb %dl, (%rax)
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rdx, -0x8(%rax)
movb %dl, (%rax)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rdx, -0x8(%rax)
movb %dl, (%rax)
leaq 0xf8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rdx, -0x8(%rax)
movl $0x0, %ecx
movq %rcx, 0x10(%rsp)
movb %dl, (%rax)
movq 0x4a05(%rip), %rax      # 0x6fd0
movl $0x0, (%rax)
leaq 0x1a2c(%rip), %r14      # 0x4004
movl %ebp, %edi
movq %rbx, %rsi
leaq 0x1a64(%rip), %rdx      # 0x4048
callq 0x22b0
cmpl $0x65, %eax
jle 0x2612
addl $-0x66, %eax
cmpl $0x10, %eax
ja 0x29fb
movslq (%r14,%rax,4), %rax
addq %r14, %rax
leaq 0xa8(%rsp), %r15
jmpq *%rax
leaq 0x68(%rsp), %r15
jmp 0x263a
cmpl $0x61, %eax
jne 0x2674
leaq 0xc8(%rsp), %r15
jmp 0x263a
leaq 0x48(%rsp), %r15
jmp 0x263a
leaq 0xe8(%rsp), %r15
jmp 0x263a
leaq 0x88(%rsp), %r15
movq 0x4977(%rip), %rax      # 0x6fb8
movq (%rax), %r12
movq 0x8(%r15), %r13
movq %r12, %rdi
callq 0x2100
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x2170
jmp 0x25d8
movb $0x1, %al
movq %rax, 0x10(%rsp)
jmp 0x25d8
cmpl $-0x1, %eax
je 0x27d4
cmpl $0x3f, %eax
jne 0x29fb
leaq 0x1a6d(%rip), %rdi      # 0x40fa
callq 0x2310
leaq 0x1a7a(%rip), %rdi      # 0x4113
callq 0x2310
leaq 0x1a8e(%rip), %rdi      # 0x4133
callq 0x2310
leaq 0x1aa8(%rip), %rdi      # 0x4159
callq 0x2310
leaq 0x1ac5(%rip), %rdi      # 0x4182
callq 0x2310
leaq 0x1ae0(%rip), %rdi      # 0x41a9
callq 0x2310
leaq 0x1b02(%rip), %rdi      # 0x41d7
callq 0x2310
leaq 0x1b28(%rip), %rdi      # 0x4209
callq 0x2310
leaq 0x1b2d(%rip), %rdi      # 0x421a
callq 0x2310
xorl %ebx, %ebx
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x2719
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2735
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2751
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2776
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x279b
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x27c0
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2080
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0xd0(%rsp)
je 0x2907
cmpq $0x0, 0xb0(%rsp)
je 0x2907
cmpq $0x0, 0x70(%rsp)
je 0x2907
cmpq $0x0, 0x50(%rsp)
je 0x2907
cmpq $0x0, 0x90(%rsp)
je 0x2907
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
xorl %eax, %eax
movq %rax, -0x8(%r14)
movb $0x0, (%r14)
leaq 0x40(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x38(%rsp), %rsi
leaq 0xf(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
leaq 0xa8(%rsp), %r8
callq 0x2b7a
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %r15
movzbl %r15b, %eax
andl $0x1, %eax
movl %eax, (%rsp)
leaq 0x48(%rsp), %rsi
leaq 0x68(%rsp), %rdx
leaq 0x88(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0xe8(%rsp), %r9
callq 0x2db0
testb %al, %al
je 0x2957
xorl %ebx, %ebx
testb $0x1, %r15b
je 0x29cc
movq 0x4719(%rip), %rdi      # 0x6fc0
leaq 0x180b(%rip), %rsi      # 0x40b9
movl $0x16, %edx
callq 0x22d0
movq 0x4701(%rip), %rdi      # 0x6fc0
callq 0x22f0
movq 0x46f5(%rip), %rdi      # 0x6fc0
leaq 0x17dd(%rip), %rsi      # 0x40af
movl $0x9, %edx
callq 0x22d0
movq 0x46dd(%rip), %rdi      # 0x6fc0
callq 0x22f0
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x22f0
jmp 0x29cc
movq 0x46b2(%rip), %rbx      # 0x6fc0
leaq 0x1743(%rip), %rsi      # 0x4058
movl $0x41, %edx
movq %rbx, %rdi
callq 0x22d0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2320
movsbl %al, %esi
movq 0x4680(%rip), %rdi      # 0x6fc0
callq 0x21a0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2160
jmp 0x26f4
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %r15b
je 0x29cc
movq 0x4657(%rip), %rdi      # 0x6fc0
leaq 0x172a(%rip), %rsi      # 0x409a
movl $0x14, %edx
callq 0x22d0
movq 0x463f(%rip), %rdi      # 0x6fc0
callq 0x22f0
cmpq $0x0, 0x20(%rsp)
je 0x29cc
movq 0x462b(%rip), %rdi      # 0x6fc0
leaq 0x1713(%rip), %rsi      # 0x40af
movl $0x9, %edx
callq 0x22d0
movq 0x4613(%rip), %rdi      # 0x6fc0
callq 0x22f0
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x22f0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x29db
callq 0x2b0a
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x26f4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2080
jmp 0x26f4
callq 0x2220
movq %rax, %rbx
jmp 0x2a17
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2a17
callq 0x2b0a
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2a35
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2080
jmp 0x2a35
jmp 0x2a32
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x2a5a
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2a76
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2a92
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2ab7
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2adc
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2080
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x2b01
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2080
movq %rbx, %rdi
callq 0x21d0
nop