#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 strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
char toupper(char);
int qualify_callsign(char *call) {
  int i;
  int len = strlen(call);
  if (len < 3)
    return -1;
  if (len > 9)
    return -1;
  if (strncasecmp(call, "N0CALL", 6) == 0)
    return -1;
  if (strncasecmp(call, "NOCALL", 6) == 0)
    return -1;
  if (strncasecmp(call, "MYCALL", 6) == 0)
    return -1;
  if (strncasecmp(call, "BLN", 3) == 0)
    return 1;
  for (i = 0; i < len; i++) {
    call[i] = toupper(call[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<qualify_callsign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    115e <qualify_callsign+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
cmpl   $0x9,-0x18(%rbp)
jle    1174 <qualify_callsign+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    119f <qualify_callsign+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11ca <qualify_callsign+0x9a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
mov    -0x10(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11f5 <qualify_callsign+0xc5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
mov    -0x10(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1220 <qualify_callsign+0xf0>
movl   $0x1,-0x4(%rbp)
jmp    1266 <qualify_callsign+0x136>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    125f <qualify_callsign+0x12f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1227 <qualify_callsign+0xf7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qualify_callsign>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    -0xa(%r15),%eax
mov    $0xffffffff,%r14d
cmp    $0xfffffff9,%eax
jb     11ef <qualify_callsign+0xbf>
lea    0xea3(%rip),%rsi
mov    %r12,%rdi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     11ef <qualify_callsign+0xbf>
lea    0xe8d(%rip),%rsi
mov    %r12,%rdi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     11ef <qualify_callsign+0xbf>
lea    0xe7b(%rip),%rsi
mov    %r12,%rdi
mov    $0x6,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     11ef <qualify_callsign+0xbf>
lea    0xe69(%rip),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1050 <strncasecmp@plt>
test   %rax,%rax
je     11e9 <qualify_callsign+0xb9>
mov    %r15d,%r15d
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <qualify_callsign+0xa0>
jmp    11ef <qualify_callsign+0xbf>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"N0CALL\00"
@.str.1 = [7 x i8] c"NOCALL\00"
@.str.2 = [7 x i8] c"MYCALL\00"
@.str.3 = [4 x i8] c"BLN\00"
define i32 @qualify_callsign(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %55
11: ; preds = %1
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 9
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %2
br label %55
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i64 @strncasecmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* %2
br label %55
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = call i64 @strncasecmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 -1, i32* %2
br label %55
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = call i64 @strncasecmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 -1, i32* %2
br label %55
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i64 @strncasecmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %2
br label %55
35: ; preds = %30
store i32 0, i32* %4
br label %36
36: ; preds = %51, %35
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %54
40: ; preds = %36
%41 = load i8*, i8** %3
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = call signext i8 @toupper(i8 signext %45)
%47 = load i8*, i8** %3
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 %46, i8* %50
br label %51
51: ; preds = %40
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %36
54: ; preds = %36
store i32 0, i32* %2
br label %55
55: ; preds = %54, %34, %29, %24, %19, %14, %10
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
@.str = [7 x i8] c"N0CALL\00"
@.str.1 = [7 x i8] c"NOCALL\00"
@.str.2 = [7 x i8] c"MYCALL\00"
@.str.3 = [4 x i8] c"BLN\00"
define i32 @qualify_callsign(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add i32 %2, -10
%4 = icmp ult i32 %3, -7
br i1 %4, label %26, label %5
5: ; preds = %1
%6 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = icmp eq i64 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %5
%9 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8
%12 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%13 = icmp eq i64 %12, 0
br i1 %13, label %26, label %14
14: ; preds = %11
%15 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = zext i32 %2 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %24, %19 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = tail call signext i8 @toupper(i8 signext %22)
store i8 %23, i8* %21
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, %18
br i1 %25, label %26, label %19
26: ; preds = %19, %14, %11, %8, %5, %1
%27 = phi i32 [ -1, %1 ], [ -1, %5 ], [ -1, %8 ], [ -1, %11 ], [ 1, %14 ], [ 0, %19 ]
ret i32 %27
}