#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 *, char **, int *, int *, int *,
                                       char **);
int validate_ranges(char *samplestring, int *parse_result, char **badtokenptr) {
  int proto1, proto2;
  char *cptr = samplestring;
  do {
    get_next_protorange(samplestring, &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    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    -0x30(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
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     116f <validate_ranges+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    1176 <validate_ranges+0x66>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_ranges>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1030 <get_next_protorange@plt>
mov    (%rbx),%eax
test   %eax,%eax
je     1140 <validate_ranges+0x30>
cmp    $0x5,%eax
jne    1169 <validate_ranges+0x59>
mov    $0x1,%eax
jmp    116b <validate_ranges+0x5b>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 = %17, %3
%13 = load i8*, i8** %5
%14 = load i32*, i32** %6
%15 = load i8**, i8*** %7
%16 = call i32 @get_next_protorange(i8* %13, i8** %10, i32* %8, i32* %9, i32* %14, i8** %15)
br label %17
17: ; preds = %12
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %12, label %21
21: ; preds = %17
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 5
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %4
br label %27
26: ; preds = %21
store i32 1, i32* %4
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %4
ret i32 %28
}

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* %0, 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
}