#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 sscanf(char const *, char *, ...);
unsigned int get_tokens(const char *str, char *mac, char *host,
                        unsigned int *port, char *passwd) {
  if (sscanf(str, " # %*s") == 1) {
    return 0;
  }
  if (sscanf(str,
             " "
             "%17[0-9a-fA-F:]"
             " "
             "%[0-9a-zA-Z._-]"
             ":%5u"
             " "
             "%17[0-9a-fA-F-]",
             mac, host, port, passwd) == 4) {
    return 0x1 | 0x2 | 0x4 | 0x8;
  }
  if (sscanf(str,
             " "
             "%17[0-9a-fA-F:]"
             " "
             "%[0-9a-zA-Z._-]"
             " "
             "%17[0-9a-fA-F-]",
             mac, host, passwd) == 3) {
    return 0x1 | 0x2 | 0x8;
  }
  if (sscanf(str,
             " "
             "%17[0-9a-fA-F:]"
             " "
             "%[0-9a-zA-Z._-]"
             ":%5u",
             mac, host, port) == 3) {
    return 0x1 | 0x2 | 0x4;
  }
  if (sscanf(str,
             " "
             "%17[0-9a-fA-F:]"
             " "
             "%[0-9a-zA-Z._-]",
             mac, host) == 2) {
    return 0x1 | 0x2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_tokens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1153 <get_tokens+0x43>
movl   $0x0,-0x4(%rbp)
jmp    1226 <get_tokens+0x116>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x4,%eax
jne    118a <get_tokens+0x7a>
movl   $0xf,-0x4(%rbp)
jmp    1226 <get_tokens+0x116>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    11bd <get_tokens+0xad>
movl   $0xb,-0x4(%rbp)
jmp    1226 <get_tokens+0x116>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    11f0 <get_tokens+0xe0>
movl   $0x7,-0x4(%rbp)
jmp    1226 <get_tokens+0x116>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    121f <get_tokens+0x10f>
movl   $0x3,-0x4(%rbp)
jmp    1226 <get_tokens+0x116>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tokens>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r13
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11d4 <get_tokens+0xc4>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    $0xf,%ebp
cmp    $0x4,%eax
je     11d4 <get_tokens+0xc4>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    $0xb,%ebp
cmp    $0x3,%eax
je     11d4 <get_tokens+0xc4>
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    $0x7,%ebp
cmp    $0x3,%eax
je     11d4 <get_tokens+0xc4>
lea    0xed9(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <sscanf@plt>
xor    %ecx,%ecx
cmp    $0x2,%eax
sete   %cl
lea    (%rcx,%rcx,2),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c" # %*s\00"
@.str.1 = [53 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]:%5u %17[0-9a-fA-F-]\00"
@.str.2 = [49 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-] %17[0-9a-fA-F-]\00"
@.str.3 = [37 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]:%5u\00"
@.str.4 = [33 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]\00"
define i32 @get_tokens(i8* %0, i8* %1, i8* %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i8* %4, i8** %11
%12 = load i8*, i8** %7
%13 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %5
store i32 0, i32* %6
br label %49
16: ; preds = %5
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = load i8*, i8** %9
%20 = load i32*, i32** %10
%21 = load i8*, i8** %11
%22 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19, i32* %20, i8* %21)
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 15, i32* %6
br label %49
25: ; preds = %16
%26 = load i8*, i8** %7
%27 = load i8*, i8** %8
%28 = load i8*, i8** %9
%29 = load i8*, i8** %11
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28, i8* %29)
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 11, i32* %6
br label %49
33: ; preds = %25
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = load i32*, i32** %10
%38 = call i32 (i8*, i8*, ...) @sscanf(i8* %34, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %35, i8* %36, i32* %37)
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 7, i32* %6
br label %49
41: ; preds = %33
%42 = load i8*, i8** %7
%43 = load i8*, i8** %8
%44 = load i8*, i8** %9
%45 = call i32 (i8*, i8*, ...) @sscanf(i8* %42, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %43, i8* %44)
%46 = icmp eq i32 %45, 2
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 3, i32* %6
br label %49
48: ; preds = %41
store i32 0, i32* %6
br label %49
49: ; preds = %48, %47, %40, %32, %24, %15
%50 = load i32, i32* %6
ret i32 %50
}

LLVM IR (-O2):
@.str = [7 x i8] c" # %*s\00"
@.str.1 = [53 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]:%5u %17[0-9a-fA-F-]\00"
@.str.2 = [49 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-] %17[0-9a-fA-F-]\00"
@.str.3 = [37 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]:%5u\00"
@.str.4 = [33 x i8] c" %17[0-9a-fA-F:] %[0-9a-zA-Z._-]\00"
define i32 @get_tokens(i8* nocapture %0, i8* %1, i8* %2, i32* %3, i8* %4) {
%6 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 1
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2, i32* %3, i8* %4)
%10 = icmp eq i32 %9, 4
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2, i8* %4)
%13 = icmp eq i32 %12, 3
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %2, i32* %3)
%16 = icmp eq i32 %15, 3
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2)
%19 = icmp eq i32 %18, 2
%20 = select i1 %19, i32 3, i32 0
br label %21
21: ; preds = %17, %14, %11, %8, %5
%22 = phi i32 [ 0, %5 ], [ 15, %8 ], [ 11, %11 ], [ 7, %14 ], [ %20, %17 ]
ret i32 %22
}