#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, 3) >= 0) {
    return 1;
  }
  if (strncmp(str2, str1, 3) <= 0) {
    return 2;
  }
  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    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jl     116f <main+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    119e <main+0x8e>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jg     1197 <main+0x87>
movl   $0x2,-0x4(%rbp)
jmp    119e <main+0x8e>
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    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jns    1174 <main+0x64>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setle  %al
add    %eax,%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 3)
%9 = icmp sge i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 1, i32* %1
br label %18
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 3)
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 2, i32* %1
br label %18
17: ; preds = %11
store i32 0, i32* %1
br label %18
18: ; preds = %17, %16, %10
%19 = load i32, i32* %1
ret i32 %19
}

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 3)
%6 = icmp sgt i64 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i64 @strncmp(i8* %4, i8* %3, i32 3)
%9 = icmp slt i64 %8, 1
%10 = select i1 %9, i32 2, i32 0
br label %11
11: ; preds = %7, %0
%12 = phi i32 [ 1, %0 ], [ %10, %7 ]
ret i32 %12
}