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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xebd(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0xc(%rbp)
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jl     117f <main+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    120b <main+0xeb>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jg     11a7 <main+0x87>
movl   $0x2,-0x4(%rbp)
jmp    120b <main+0xeb>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x10(%rbp),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11dc <main+0xbc>
movl   $0x3,-0x4(%rbp)
jmp    120b <main+0xeb>
lea    -0xa(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1204 <main+0xe4>
movl   $0x4,-0x4(%rbp)
jmp    120b <main+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
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    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jns    11db <main+0xbb>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
jle    11db <main+0xbb>
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jne    11db <main+0xbb>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
shl    $0x2,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
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 6)
%9 = icmp sge i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 1, i32* %1
br label %33
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 6)
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 2, i32* %1
br label %33
17: ; preds = %11
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%23 = call i64 @strncmp(i8* %21, i8* %22, i32 6)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
store i32 3, i32* %1
br label %33
26: ; preds = %17
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%29 = call i64 @strncmp(i8* %27, i8* %28, i32 6)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 4, i32* %1
br label %33
32: ; preds = %26
store i32 0, i32* %1
br label %33
33: ; preds = %32, %31, %25, %16, %10
%34 = load i32, i32* %1
ret i32 %34
}

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