#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ printf(char *, unsigned int, ...);
char *strtok(char *, char *);
void parsePorts(unsigned int *ports[2], char *in) {
  char *token = strtok(in, "-");
  (*ports)[0] = (unsigned int)atoi(token);
  token = strtok(NULL, "-");
  if (token != NULL) {
    (*ports)[1] = (unsigned int)atoi(token);
    printf("\t+Enumerating services from port range\t[%u] to [%u]\n",
           (*ports)[0], (*ports)[1]);
  } else {
    (*ports)[0] = (unsigned int)atoi(in);
    printf("\t+Enumerating services at port\t\t[%u]\n", (*ports)[0]);
  }
}


x86 assembly (clang, -O0):
<parsePorts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe8d(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c2 <parsePorts+0x92>
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%edx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <parsePorts+0xbd>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsePorts>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebe(%rip),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    (%rbx),%rcx
mov    %eax,(%rcx)
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     118e <parsePorts+0x5e>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    (%rbx),%rcx
mov    %eax,0x4(%rcx)
mov    (%rcx),%esi
lea    0xe82(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    (%rbx),%rcx
mov    %eax,(%rcx)
lea    0xe95(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [53 x i8] c"\09+Enumerating services from port range\09[%u] to [%u]\0A\00"
@.str.2 = [38 x i8] c"\09+Enumerating services at port\09\09[%u]\0A\00"
define void @parsePorts(i32** %0, i8* %1) {
%3 = alloca i32**
%4 = alloca i8*
%5 = alloca i8*
store i32** %0, i32*** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = call i64 @atoi(i8* %8)
%10 = trunc i64 %9 to i32
%11 = load i32**, i32*** %3
%12 = load i32*, i32** %11
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %10, i32* %13
%14 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %33
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i64 @atoi(i8* %18)
%20 = trunc i64 %19 to i32
%21 = load i32**, i32*** %3
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 1
store i32 %20, i32* %23
%24 = load i32**, i32*** %3
%25 = load i32*, i32** %24
%26 = getelementptr inbounds i32, i32* %25, i64 0
%27 = load i32, i32* %26
%28 = load i32**, i32*** %3
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = load i32, i32* %30
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %31)
br label %45
33: ; preds = %2
%34 = load i8*, i8** %4
%35 = call i64 @atoi(i8* %34)
%36 = trunc i64 %35 to i32
%37 = load i32**, i32*** %3
%38 = load i32*, i32** %37
%39 = getelementptr inbounds i32, i32* %38, i64 0
store i32 %36, i32* %39
%40 = load i32**, i32*** %3
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 0
%43 = load i32, i32* %42
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %33, %17
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [53 x i8] c"\09+Enumerating services from port range\09[%u] to [%u]\0A\00"
@.str.2 = [38 x i8] c"\09+Enumerating services at port\09\09[%u]\0A\00"
define void @parsePorts(i32** nocapture %0, i8* %1) {
%3 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @atoi(i8* %3)
%5 = trunc i64 %4 to i32
%6 = load i32*, i32** %0
store i32 %5, i32* %6
%7 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = tail call i64 @atoi(i8* %7)
%11 = trunc i64 %10 to i32
%12 = load i32*, i32** %0
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %11, i32* %13
%14 = load i32, i32* %12
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %11)
br label %21
16: ; preds = %2
%17 = tail call i64 @atoi(i8* %1)
%18 = trunc i64 %17 to i32
%19 = load i32*, i32** %0
store i32 %18, i32* %19
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %21
21: ; preds = %16, %9
ret void
}