#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*/ get_next_protorange(char **, unsigned int *, unsigned int *,
                                       int *, char **);
int validate_ranges(char *samplestring, int *parse_result, char **badtokenptr) {
  unsigned int proto1, proto2;
  char *cptr = samplestring;
  do {
    get_next_protorange(&cptr, &proto1, &proto2, parse_result, badtokenptr);
  } while (*parse_result == 0);
  if (*parse_result != 5)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<validate_ranges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    -0x30(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <get_next_protorange@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     112c <validate_ranges+0x1c>
mov    -0x18(%rbp),%rax
cmpl   $0x5,(%rax)
je     116b <validate_ranges+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    1172 <validate_ranges+0x62>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_ranges>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,(%rsp)
mov    %rsp,%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <get_next_protorange@plt>
mov    (%rbx),%eax
test   %eax,%eax
je     1140 <validate_ranges+0x30>
cmp    $0x5,%eax
jne    1166 <validate_ranges+0x56>
mov    $0x1,%eax
jmp    1168 <validate_ranges+0x58>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @validate_ranges(i8* %0, i32* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i8** %6 to i8*
store i8* %0, i8** %6
br label %10
10: ; preds = %10, %3
%11 = call i32 @get_next_protorange(i8** %6, i32* %4, i32* %5, i32* %1, i8** %2)
%12 = load i32, i32* %1
switch i32 %12, label %13 [
i32 0, label %10
i32 5, label %14
]
13: ; preds = %10
br label %14
14: ; preds = %10, %13
%15 = phi i32 [ 0, %13 ], [ 1, %10 ]
ret i32 %15
}