#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(char *);
int /*<<< orphan*/ checkIfNumber(char *);
int checkIfAllMemoryLocationsAreValid(char **tokens) {
  while (*tokens) {
    if (!checkIfNumber(*tokens) || atoi(*tokens) < 0 || atoi(*tokens) >= 65536)
      return 0;
    tokens++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkIfAllMemoryLocationsAreValid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1198 <checkIfAllMemoryLocationsAreValid+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <checkIfNumber@plt>
cmp    $0x0,%eax
je     117b <checkIfAllMemoryLocationsAreValid+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atoi@plt>
cmp    $0x0,%eax
jl     117b <checkIfAllMemoryLocationsAreValid+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atoi@plt>
cmp    $0x10000,%eax
jl     1187 <checkIfAllMemoryLocationsAreValid+0x67>
movl   $0x0,-0x4(%rbp)
jmp    119f <checkIfAllMemoryLocationsAreValid+0x7f>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <checkIfAllMemoryLocationsAreValid+0xc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIfAllMemoryLocationsAreValid>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1165 <checkIfAllMemoryLocationsAreValid+0x45>
add    $0x8,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <checkIfNumber@plt>
test   %eax,%eax
je     116a <checkIfAllMemoryLocationsAreValid+0x4a>
mov    -0x8(%rbx),%rdi
call   1040 <atoi@plt>
cmp    $0x10000,%eax
jae    116a <checkIfAllMemoryLocationsAreValid+0x4a>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <checkIfAllMemoryLocationsAreValid+0x20>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkIfAllMemoryLocationsAreValid(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
br label %4
4: ; preds = %24, %1
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %9
%11 = call i32 @checkIfNumber(i8* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i8**, i8*** %3
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = icmp sge i32 %21, 65536
br i1 %22, label %23, label %24
23: ; preds = %18, %13, %8
store i32 0, i32* %2
br label %28
24: ; preds = %18
%25 = load i8**, i8*** %3
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %3
br label %4
27: ; preds = %4
store i32 1, i32* %2
br label %28
28: ; preds = %27, %23
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @checkIfAllMemoryLocationsAreValid(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %17, label %7
4: ; preds = %12
%5 = load i8*, i8** %16
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %1, %4
%8 = phi i8* [ %5, %4 ], [ %2, %1 ]
%9 = phi i8** [ %16, %4 ], [ %0, %1 ]
%10 = tail call i32 @checkIfNumber(i8* %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i8*, i8** %9
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp ugt i32 %14, 65535
%16 = getelementptr inbounds i8*, i8** %9, i64 1
br i1 %15, label %17, label %4
17: ; preds = %12, %7, %4, %1
%18 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 0, %7 ], [ 0, %12 ]
ret i32 %18
}