#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*/ printf(char *, char *, int);
int strncasecmp(char *, char *, int);
int test_strncasecmp(void) {
  do {
    if (!(strncasecmp("a", "Aa", 1) == 0)) {
      printf("expression '%s' untrue at %d\n",
             "strncasecmp(\"a\", \"Aa\", 1) == 0", 51);
      return 0;
    }
  } while (0);
  do {
    if (!(strncasecmp("a", "B", 0) == 0)) {
      printf("expression '%s' untrue at %d\n",
             "strncasecmp(\"a\", \"B\", 0) == 0", 52);
      return 0;
    }
  } while (0);
  do {
    if (!(strncasecmp("bLaH a", "blah b", 6) == -1)) {
      printf("expression '%s' untrue at %d\n",
             "strncasecmp(\"bLaH a\", \"blah b\", 6) == -1", 53);
      return 0;
    }
  } while (0);
  do {
    if (!(strncasecmp("AAa", "AAA", 3) == 0)) {
      printf("expression '%s' untrue at %d\n",
             "strncasecmp(\"AAa\", \"AAA\", 3) == 0", 54);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_strncasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf33(%rip),%rdi
lea    0xf5f(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     116d <test_strncasecmp+0x4d>
lea    0xeb0(%rip),%rdi
lea    0xec7(%rip),%rsi
mov    $0x33,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1263 <test_strncasecmp+0x143>
jmp    1172 <test_strncasecmp+0x52>
jmp    1177 <test_strncasecmp+0x57>
lea    0xee4(%rip),%rdi
lea    0xeb8(%rip),%rsi
xor    %edx,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     11b9 <test_strncasecmp+0x99>
lea    0xe64(%rip),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x34,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1263 <test_strncasecmp+0x143>
jmp    11be <test_strncasecmp+0x9e>
jmp    11c3 <test_strncasecmp+0xa3>
lea    0xe93(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
cmp    $0xffffffff,%eax
je     1208 <test_strncasecmp+0xe8>
lea    0xe15(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x35,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1263 <test_strncasecmp+0x143>
jmp    120d <test_strncasecmp+0xed>
jmp    1212 <test_strncasecmp+0xf2>
lea    0xe7b(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1257 <test_strncasecmp+0x137>
lea    0xdc6(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x36,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1263 <test_strncasecmp+0x143>
jmp    125c <test_strncasecmp+0x13c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strncasecmp>:
push   %rbx
lea    0xf3a(%rip),%rdi
lea    0xf66(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     115c <test_strncasecmp+0x3c>
lea    0xebc(%rip),%rdi
lea    0xed3(%rip),%rsi
mov    $0x33,%edx
call   1030 <printf@plt>
xor    %ebx,%ebx
jmp    11f2 <test_strncasecmp+0xd2>
lea    0xeff(%rip),%rdi
lea    0xed3(%rip),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     118c <test_strncasecmp+0x6c>
lea    0xe82(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x34,%edx
jmp    11ed <test_strncasecmp+0xcd>
lea    0xeca(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
cmp    $0xffffffff,%eax
je     11be <test_strncasecmp+0x9e>
lea    0xe50(%rip),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x35,%edx
jmp    11ed <test_strncasecmp+0xcd>
lea    0xecf(%rip),%rdi
lea    0xecc(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11f6 <test_strncasecmp+0xd6>
lea    0xe1f(%rip),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x36,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x1,%ebx
jmp    11f2 <test_strncasecmp+0xd2>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"Aa\00"
@.str.2 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.3 = [31 x i8] c"strncasecmp(\22a\22, \22Aa\22, 1) == 0\00"
@.str.4 = [2 x i8] c"B\00"
@.str.5 = [30 x i8] c"strncasecmp(\22a\22, \22B\22, 0) == 0\00"
@.str.6 = [7 x i8] c"bLaH a\00"
@.str.7 = [7 x i8] c"blah b\00"
@.str.8 = [41 x i8] c"strncasecmp(\22bLaH a\22, \22blah b\22, 6) == -1\00"
@.str.9 = [4 x i8] c"AAa\00"
@.str.10 = [4 x i8] c"AAA\00"
@.str.11 = [34 x i8] c"strncasecmp(\22AAa\22, \22AAA\22, 3) == 0\00"
define i32 @test_strncasecmp() {
%1 = alloca i32
br label %2
2: ; preds = %0
%3 = call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 51)
store i32 0, i32* %1
br label %30
7: ; preds = %2
br label %8
8: ; preds = %7
br label %9
9: ; preds = %8
%10 = call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 52)
store i32 0, i32* %1
br label %30
14: ; preds = %9
br label %15
15: ; preds = %14
br label %16
16: ; preds = %15
%17 = call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%18 = icmp eq i32 %17, -1
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i32 53)
store i32 0, i32* %1
br label %30
21: ; preds = %16
br label %22
22: ; preds = %21
br label %23
23: ; preds = %22
%24 = call i32 @strncasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 54)
store i32 0, i32* %1
br label %30
28: ; preds = %23
br label %29
29: ; preds = %28
store i32 1, i32* %1
br label %30
30: ; preds = %29, %26, %19, %12, %5
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"Aa\00"
@.str.2 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.3 = [31 x i8] c"strncasecmp(\22a\22, \22Aa\22, 1) == 0\00"
@.str.4 = [2 x i8] c"B\00"
@.str.5 = [30 x i8] c"strncasecmp(\22a\22, \22B\22, 0) == 0\00"
@.str.6 = [7 x i8] c"bLaH a\00"
@.str.7 = [7 x i8] c"blah b\00"
@.str.8 = [41 x i8] c"strncasecmp(\22bLaH a\22, \22blah b\22, 6) == -1\00"
@.str.9 = [4 x i8] c"AAa\00"
@.str.10 = [4 x i8] c"AAA\00"
@.str.11 = [34 x i8] c"strncasecmp(\22AAa\22, \22AAA\22, 3) == 0\00"
define i32 @test_strncasecmp() {
%1 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
%2 = icmp eq i32 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 51)
br label %20
5: ; preds = %0
%6 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 52)
br label %20
10: ; preds = %5
%11 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%12 = icmp eq i32 %11, -1
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i32 53)
br label %20
15: ; preds = %10
%16 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 54)
br label %20
20: ; preds = %15, %18, %13, %8, %3
%21 = phi i32 [ 0, %18 ], [ 0, %13 ], [ 0, %8 ], [ 0, %3 ], [ 1, %15 ]
ret i32 %21
}