#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*/ printf(char *, char *, char *, int);
int strncmp(char *, char *, int);
int main(void) {
  char s1[1000] = "aaa";
  char s2[1000] = "aba";
  char s3[1000] = "abb";
  char s4[1000] = "aca";
  printf(
      "Comparing the first 2 characters of \"%s\" to \"%s\" results in: %d\n",
      s1, s2, strncmp(s1, s2, 2));
  printf(
      "Comparing the first 2 characters of \"%s\" to \"%s\" results in: %d\n",
      s3, s2, strncmp(s3, s2, 2));
  printf(
      "Comparing the first 2 characters of \"%s\" to \"%s\" results in: %d\n",
      s4, s2, strncmp(s4, s2, 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xff0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
movb   $0x61,-0x3f0(%rbp)
movb   $0x61,-0x3ef(%rbp)
movb   $0x61,-0x3ee(%rbp)
lea    -0x7e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
movb   $0x61,-0x7e0(%rbp)
movb   $0x62,-0x7df(%rbp)
movb   $0x61,-0x7de(%rbp)
lea    -0xbd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
movb   $0x61,-0xbd0(%rbp)
movb   $0x62,-0xbcf(%rbp)
movb   $0x62,-0xbce(%rbp)
lea    -0xfc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
movb   $0x61,-0xfc0(%rbp)
movb   $0x63,-0xfbf(%rbp)
movb   $0x61,-0xfbe(%rbp)
lea    -0x3f0(%rbp),%rax
mov    %rax,-0xff0(%rbp)
lea    -0x7e0(%rbp),%rax
mov    %rax,-0xfe8(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    -0xff0(%rbp),%rsi
mov    -0xfe8(%rbp),%rdx
mov    %eax,%ecx
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
lea    -0xbd0(%rbp),%rax
mov    %rax,-0xfe0(%rbp)
lea    -0x7e0(%rbp),%rax
mov    %rax,-0xfd8(%rbp)
lea    -0xbd0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    -0xfe0(%rbp),%rsi
mov    -0xfd8(%rbp),%rdx
mov    %eax,%ecx
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
lea    -0xfc0(%rbp),%rax
mov    %rax,-0xfd0(%rbp)
lea    -0x7e0(%rbp),%rax
mov    %rax,-0xfc8(%rbp)
lea    -0xfc0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    -0xfd0(%rbp),%rsi
mov    -0xfc8(%rbp),%rdx
mov    %eax,%ecx
lea    0xd33(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xff0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfc0,%rsp
lea    0xbd0(%rsp),%r14
mov    $0x3e8,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movw   $0x6161,0xbd0(%rsp)
movb   $0x61,0xbd2(%rsp)
61
lea    0x7e0(%rsp),%rbx
mov    $0x3e8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movw   $0x6261,0x7e0(%rsp)
movb   $0x61,0x7e2(%rsp)
61
lea    0x3f0(%rsp),%r12
mov    $0x3e8,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movw   $0x6261,0x3f0(%rsp)
movb   $0x62,0x3f2(%rsp)
62
mov    %rsp,%r15
mov    $0x3e8,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movw   $0x6361,(%rsp)
movb   $0x61,0x2(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
lea    0xe11(%rip),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Comparing the first 2 characters of \22%s\22 to \22%s\22 results in: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
%6 = bitcast [1000 x i8]* %2 to i8*
%7 = bitcast i8* %6 to [1000 x i8]*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i32 0, i32 0
store i8 97, i8* %8
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i32 0, i32 1
store i8 97, i8* %9
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i32 0, i32 2
store i8 97, i8* %10
%11 = bitcast [1000 x i8]* %3 to i8*
%12 = bitcast i8* %11 to [1000 x i8]*
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i32 0, i32 0
store i8 97, i8* %13
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i32 0, i32 1
store i8 98, i8* %14
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i32 0, i32 2
store i8 97, i8* %15
%16 = bitcast [1000 x i8]* %4 to i8*
%17 = bitcast i8* %16 to [1000 x i8]*
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %17, i32 0, i32 0
store i8 97, i8* %18
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %17, i32 0, i32 1
store i8 98, i8* %19
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %17, i32 0, i32 2
store i8 98, i8* %20
%21 = bitcast [1000 x i8]* %5 to i8*
%22 = bitcast i8* %21 to [1000 x i8]*
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %22, i32 0, i32 0
store i8 97, i8* %23
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %22, i32 0, i32 1
store i8 99, i8* %24
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %22, i32 0, i32 2
store i8 97, i8* %25
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%30 = call i32 @strncmp(i8* %28, i8* %29, i32 2)
%31 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27, i32 %30)
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%36 = call i32 @strncmp(i8* %34, i8* %35, i32 2)
%37 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33, i32 %36)
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%42 = call i32 @strncmp(i8* %40, i8* %41, i32 2)
%43 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %38, i8* %39, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [65 x i8] c"Comparing the first 2 characters of \22%s\22 to \22%s\22 results in: %d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
store i8 97, i8* %5
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 1
store i8 97, i8* %6
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 2
store i8 97, i8* %7
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 97, i8* %8
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 1
store i8 98, i8* %9
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 2
store i8 97, i8* %10
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
store i8 97, i8* %11
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 1
store i8 98, i8* %12
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 2
store i8 98, i8* %13
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
store i8 97, i8* %14
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 1
store i8 99, i8* %15
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 2
store i8 97, i8* %16
%17 = call i32 @strncmp(i8* %5, i8* %8, i32 2)
%18 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %8, i32 %17)
%19 = call i32 @strncmp(i8* %11, i8* %8, i32 2)
%20 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %8, i32 %19)
%21 = call i32 @strncmp(i8* %14, i8* %8, i32 2)
%22 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %8, i32 %21)
ret i32 0
}