#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();
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char str[8];
  strcpy(str, "3141");
  if (memcmp(str, str + 2, 0) != 0)
    abort();
  if (memcmp(str + 1, str + 3, 0) != 0)
    abort();
  if (memcmp(str + 1, str + 3, 1) != 0)
    abort();
  if (memcmp(str, str + 2, 1) >= 0)
    abort();
  if (memcmp(str + 2, str, 1) <= 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xc(%rbp),%rdi
lea    -0xc(%rbp),%rsi
add    $0x2,%rsi
xor    %edx,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1173 <main+0x43>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0xc(%rbp),%rdi
add    $0x1,%rdi
lea    -0xc(%rbp),%rsi
add    $0x3,%rsi
xor    %edx,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     119b <main+0x6b>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0xc(%rbp),%rdi
add    $0x1,%rdi
lea    -0xc(%rbp),%rsi
add    $0x3,%rsi
mov    $0x1,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     11c6 <main+0x96>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0xc(%rbp),%rdi
lea    -0xc(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jl     11ed <main+0xbd>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0xc(%rbp),%rdi
add    $0x2,%rdi
lea    -0xc(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jg     1214 <main+0xe4>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xa(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11cf <main+0x9f>
lea    0x9(%rsp),%rbx
lea    0xb(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11cf <main+0x9f>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11cf <main+0x9f>
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jns    11cf <main+0x9f>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jle    11cf <main+0x9f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"3141\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %6, i64 2
%8 = call i64 @memcmp(i8* %5, i8* %7, i32 0)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %0
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 3
%17 = call i64 @memcmp(i8* %14, i8* %16, i32 0)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %12
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = call i64 @memcmp(i8* %23, i8* %25, i32 1)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %21
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = call i64 @memcmp(i8* %31, i8* %33, i32 1)
%35 = icmp sge i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %30
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%42 = call i64 @memcmp(i8* %40, i8* %41, i32 1)
%43 = icmp sle i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 (...) @abort()
unreachable
46: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"3141\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 2
%5 = call i64 @memcmp(i8* %2, i8* %4, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (...) @abort()
unreachable
9: ; preds = %0
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 1
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 3
%12 = call i64 @memcmp(i8* %10, i8* %11, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %9
%17 = call i64 @memcmp(i8* %10, i8* %11, i32 1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %16
%22 = call i64 @memcmp(i8* %2, i8* %4, i32 1)
%23 = icmp sgt i64 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %21
%27 = call i64 @memcmp(i8* %4, i8* %2, i32 1)
%28 = icmp slt i64 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %26
ret i32 0
}