#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*/ abort();
int strncmp(char const *, char const *, int);
__attribute__((no)) void test_strncmp_5(const char *str1, const char *str2,
                                        int expect) {
  int r;
  r = strncmp(str1, str2, 5);
  if (r < 0 && !(expect < 0))
    abort();
  if (r > 0 && !(expect > 0))
    abort();
  if (r == 0 && !(expect == 0))
    abort();
}


x86 assembly (clang, -O0):
<test_strncmp_5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1163 <test_strncmp_5+0x43>
cmpl   $0x0,-0x14(%rbp)
jl     1163 <test_strncmp_5+0x43>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x18(%rbp)
jle    117e <test_strncmp_5+0x5e>
cmpl   $0x0,-0x14(%rbp)
jg     117e <test_strncmp_5+0x5e>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1199 <test_strncmp_5+0x79>
cmpl   $0x0,-0x14(%rbp)
je     1199 <test_strncmp_5+0x79>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strncmp_5>:
push   %rbx
mov    %edx,%ebx
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %ebx,%ebx
js     1135 <test_strncmp_5+0x15>
test   %eax,%eax
js     1147 <test_strncmp_5+0x27>
test   %ebx,%ebx
jg     113d <test_strncmp_5+0x1d>
test   %eax,%eax
jg     1147 <test_strncmp_5+0x27>
test   %ebx,%ebx
je     1145 <test_strncmp_5+0x25>
test   %eax,%eax
je     1147 <test_strncmp_5+0x27>
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @test_strncmp_5(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 @strncmp(i8* %8, i8* %9, i32 5)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %13, %3
%19 = load i32, i32* %7
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %21, %18
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %29, %26
ret void
}

LLVM IR (-O2):
define void @test_strncmp_5(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strncmp(i8* %0, i8* %1, i32 5)
%5 = icmp sgt i32 %4, -1
%6 = icmp slt i32 %2, 0
%7 = or i1 %6, %5
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %3
%11 = icmp slt i32 %4, 1
%12 = icmp sgt i32 %2, 0
%13 = or i1 %12, %11
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %10
%17 = icmp ne i32 %4, 0
%18 = icmp eq i32 %2, 0
%19 = or i1 %18, %17
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call i32 (...) @abort()
unreachable
22: ; preds = %16
ret void
}