#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__ match_char(char const **, char const *, char);
scalar_t__ match_ipv6_address(char const **, char const *);
scalar_t__ match_ipvfuture(char const **, char const *);
int match_ip_literal(char const **str, char const *end, int *type) {
  char const *i = *str;
  int temp = 0;
  if (match_char(&i, end, '[')) {
    if (match_ipv6_address(&i, end)) {
      temp = (3);
    } else if (match_ipvfuture(&i, end)) {
      temp = (4);
    }
    if (temp != 0 && match_char(&i, end, ']')) {
      *str = i;
      *type = temp;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_ip_literal>:
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),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x5b,%edx
call   1050 <match_char@plt>
cmp    $0x0,%rax
je     1203 <match_ip_literal+0xd3>
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1040 <match_ipv6_address@plt>
cmp    $0x0,%rax
je     1195 <match_ip_literal+0x65>
movl   $0x3,-0x2c(%rbp)
jmp    11b8 <match_ip_literal+0x88>
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1030 <match_ipvfuture@plt>
cmp    $0x0,%rax
je     11b3 <match_ip_literal+0x83>
movl   $0x4,-0x2c(%rbp)
jmp    11b8 <match_ip_literal+0x88>
cmpl   $0x0,-0x2c(%rbp)
je     11fe <match_ip_literal+0xce>
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x5d,%edx
call   1050 <match_char@plt>
cmp    $0x0,%rax
je     11fe <match_ip_literal+0xce>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    120a <match_ip_literal+0xda>
jmp    1203 <match_ip_literal+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_ip_literal>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rdi),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x5b,%edx
call   1050 <match_char@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11ba <match_ip_literal+0x8a>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <match_ipv6_address@plt>
mov    $0x3,%r12d
test   %rax,%rax
jne    1193 <match_ip_literal+0x63>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <match_ipvfuture@plt>
mov    $0x4,%r12d
test   %rax,%rax
je     11ba <match_ip_literal+0x8a>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5d,%edx
call   1050 <match_char@plt>
test   %rax,%rax
je     11ba <match_ip_literal+0x8a>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
mov    %r12d,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @match_ip_literal(i8** %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = load i8**, i8*** %5
%11 = load i8*, i8** %10
store i8* %11, i8** %8
store i32 0, i32* %9
%12 = load i8*, i8** %6
%13 = call i64 @match_char(i8** %8, i8* %12, i8 signext 91)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i64 @match_ipv6_address(i8** %8, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 3, i32* %9
br label %26
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = call i64 @match_ipvfuture(i8** %8, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 4, i32* %9
br label %25
25: ; preds = %24, %20
br label %26
26: ; preds = %25, %19
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i8*, i8** %6
%31 = call i64 @match_char(i8** %8, i8* %30, i8 signext 93)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %8
%35 = load i8**, i8*** %5
store i8* %34, i8** %35
%36 = load i32, i32* %9
%37 = load i32*, i32** %7
store i32 %36, i32* %37
store i32 1, i32* %4
br label %40
38: ; preds = %29, %26
br label %39
39: ; preds = %38, %3
store i32 0, i32* %4
br label %40
40: ; preds = %39, %33
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @match_ip_literal(i8** nocapture %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = load i8*, i8** %0
store i8* %6, i8** %4
%7 = call i64 @match_char(i8** %4, i8* %1, i8 signext 91)
%8 = icmp eq i64 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %3
%10 = call i64 @match_ipv6_address(i8** %4, i8* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i64 @match_ipvfuture(i8** %4, i8* %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %9, %12
%16 = phi i32 [ 4, %12 ], [ 3, %9 ]
%17 = call i64 @match_char(i8** %4, i8* %1, i8 signext 93)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = load i8*, i8** %4
store i8* %20, i8** %0
store i32 %16, i32* %2
br label %21
21: ; preds = %3, %15, %12, %19
%22 = phi i32 [ 1, %19 ], [ 0, %12 ], [ 0, %15 ], [ 0, %3 ]
ret i32 %22
}