#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 */
scalar_t__ strncmp(char *, char *, int);
int main() {
  char str1[] = "aaXaa";
  char str2[] = "aaYaa";
  if (strncmp(str1, str2, 2) != 0) {
    return 1;
  }
  if (strncmp(str2, str1, 2) != 0) {
    return 2;
  }
  if (strncmp(str1, str2, 5) >= 0) {
    return 3;
  }
  if (strncmp(str2, str1, 5) <= 0) {
    return 4;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xed5(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xecd(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0xc(%rbp)
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     116f <main+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    11ee <main+0xde>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1197 <main+0x87>
movl   $0x2,-0x4(%rbp)
jmp    11ee <main+0xde>
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jl     11bf <main+0xaf>
movl   $0x3,-0x4(%rbp)
jmp    11ee <main+0xde>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jg     11e7 <main+0xd7>
movl   $0x4,-0x4(%rbp)
jmp    11ee <main+0xde>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movw   $0x61,0x14(%rsp)
movl   $0x61586161,0x10(%rsp)
61
movw   $0x61,0xc(%rsp)
movl   $0x61596161,0x8(%rsp)
61
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1158 <main+0x48>
add    $0x18,%rsp
ret
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
jne    1153 <main+0x43>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jns    1153 <main+0x43>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setle  %al
shl    $0x2,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.str1 = [6 x i8] c"aaXaa\00"
@__const.main.str2 = [6 x i8] c"aaYaa\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
store i32 0, i32* %1
%4 = bitcast [6 x i8]* %2 to i8*
%5 = bitcast [6 x i8]* %3 to i8*
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = call i64 @strncmp(i8* %6, i8* %7, i32 2)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 1, i32* %1
br label %30
11: ; preds = %0
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%14 = call i64 @strncmp(i8* %12, i8* %13, i32 2)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 2, i32* %1
br label %30
17: ; preds = %11
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%20 = call i64 @strncmp(i8* %18, i8* %19, i32 5)
%21 = icmp sge i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 3, i32* %1
br label %30
23: ; preds = %17
%24 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%26 = call i64 @strncmp(i8* %24, i8* %25, i32 5)
%27 = icmp sle i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 4, i32* %1
br label %30
29: ; preds = %23
store i32 0, i32* %1
br label %30
30: ; preds = %29, %28, %22, %16, %10
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@__const.main.str1 = [6 x i8] c"aaXaa\00"
@__const.main.str2 = [6 x i8] c"aaYaa\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = call i64 @strncmp(i8* %3, i8* %4, i32 2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0
%8 = call i64 @strncmp(i8* %4, i8* %3, i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = call i64 @strncmp(i8* %3, i8* %4, i32 5)
%12 = icmp sgt i64 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = call i64 @strncmp(i8* %4, i8* %3, i32 5)
%15 = icmp slt i64 %14, 1
%16 = select i1 %15, i32 4, i32 0
br label %17
17: ; preds = %13, %10, %7, %0
%18 = phi i32 [ 1, %0 ], [ 2, %7 ], [ 3, %10 ], [ %16, %13 ]
ret i32 %18
}