#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 */
typedef int /*<<< orphan*/ airportPrefixWithoutDefault;
typedef int /*<<< orphan*/ airportPrefixUsingMPS;

/* Variables and functions */
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *defaultWindUnitsForAirport(char *airportId) {
  int i;
  static char *airportPrefixUsingMPS[1] = {"Z"},
              *airportPrefixWithoutDefault[1] = {"U"};
  if (strlen(airportId) != 4) {
    return "";
  }
  for (i = 0;
       i < sizeof(airportPrefixUsingMPS) / sizeof(airportPrefixUsingMPS[0]);
       i++) {
    if (strncmp(airportId, airportPrefixUsingMPS[i], 1) == 0) {
      return "MPS";
    }
  }
  for (i = 0; i < sizeof(airportPrefixWithoutDefault) /
                      sizeof(airportPrefixWithoutDefault[0]);
       i++) {
    if (strncmp(airportId, airportPrefixWithoutDefault[i], 1) == 0) {
      return "";
    }
  }
  return "KT";
}


x86 assembly (clang, -O0):
<defaultWindUnitsForAirport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
je     114e <defaultWindUnitsForAirport+0x2e>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <defaultWindUnitsForAirport+0xf7>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x1,%rax
jae    11ad <defaultWindUnitsForAirport+0x8d>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2ebe(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119a <defaultWindUnitsForAirport+0x7a>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <defaultWindUnitsForAirport+0xf7>
jmp    119f <defaultWindUnitsForAirport+0x7f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <defaultWindUnitsForAirport+0x35>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x1,%rax
jae    120c <defaultWindUnitsForAirport+0xec>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2e67(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11f9 <defaultWindUnitsForAirport+0xd9>
lea    0xe17(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1217 <defaultWindUnitsForAirport+0xf7>
jmp    11fe <defaultWindUnitsForAirport+0xde>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <defaultWindUnitsForAirport+0x94>
lea    0xdf5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<defaultWindUnitsForAirport>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    1172 <defaultWindUnitsForAirport+0x52>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     117b <defaultWindUnitsForAirport+0x5b>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
lea    0xea2(%rip),%rcx
lea    0xe9c(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe8e(%rip),%rax
pop    %rbx
ret
lea    0xe82(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@defaultWindUnitsForAirport.airportPrefixUsingMPS = internal global [1 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)]
@.str = [2 x i8] c"Z\00"
@defaultWindUnitsForAirport.airportPrefixWithoutDefault = internal global [1 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str.1 = [2 x i8] c"U\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"MPS\00"
@.str.4 = [3 x i8] c"KT\00"
define i8* @defaultWindUnitsForAirport(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp ne i32 %6, 4
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %46
9: ; preds = %1
store i32 0, i32* %4
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = icmp ult i64 %12, 1
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1 x i8*], [1 x i8*]* @defaultWindUnitsForAirport.airportPrefixUsingMPS, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @strncmp(i8* %15, i8* %19, i32 1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %14
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %46
23: ; preds = %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %10
27: ; preds = %10
store i32 0, i32* %4
br label %28
28: ; preds = %42, %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = icmp ult i64 %30, 1
br i1 %31, label %32, label %45
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1 x i8*], [1 x i8*]* @defaultWindUnitsForAirport.airportPrefixWithoutDefault, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strncmp(i8* %33, i8* %37, i32 1)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %32
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %46
41: ; preds = %32
br label %42
42: ; preds = %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %28
45: ; preds = %28
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %46
46: ; preds = %45, %40, %22, %8
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@.str = [2 x i8] c"Z\00"
@.str.1 = [2 x i8] c"U\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"MPS\00"
@.str.4 = [3 x i8] c"KT\00"
define i8* @defaultWindUnitsForAirport(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 4
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
br label %11
11: ; preds = %7, %4, %1
%12 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %4 ], [ %10, %7 ]
ret i8* %12
}