#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  int valid = 0;
  char str1[8];
  char str2[8];
  str2[0] = 'S';
  str2[1] = 'E';
  str2[2] = 'C';
  str2[3] = 'R';
  str2[4] = 'E';
  str2[5] = 'T';
  str2[6] = (char)0;
  printf("READING:\n\n");
  gets(str1);
  printf("READ:\n\n");
  if (strncmp(str1, str2, 8) == 0) {
    valid = 1;
  }
  printf("buffer1: str1=%s str2=%s valid=%d\n", str1, str2, valid);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x53,-0x24(%rbp)
movb   $0x45,-0x23(%rbp)
movb   $0x43,-0x22(%rbp)
movb   $0x52,-0x21(%rbp)
movb   $0x45,-0x20(%rbp)
movb   $0x54,-0x1f(%rbp)
movb   $0x0,-0x1e(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rdi
call   1050 <gets@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c1 <main+0x81>
movl   $0x1,-0x14(%rbp)
lea    -0x1c(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x52434553,0x8(%rsp)
52
movw   $0x5445,0xc(%rsp)
movb   $0x0,0xe(%rsp)
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"READING:\0A\0A\00"
@.str.1 = [8 x i8] c"READ:\0A\0A\00"
@.str.2 = [35 x i8] c"buffer1: str1=%s str2=%s valid=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8 x i8]
%8 = alloca [8 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
store i8 83, i8* %9
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 1
store i8 69, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 2
store i8 67, i8* %11
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 3
store i8 82, i8* %12
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 4
store i8 69, i8* %13
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 5
store i8 84, i8* %14
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 6
store i8 0, i8* %15
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%18 = call i32 @gets(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%22 = call i64 @strncmp(i8* %20, i8* %21, i32 8)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 1, i32* %6
br label %25
25: ; preds = %24, %2
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %27, i32 %28)
%30 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.2 = [35 x i8] c"buffer1: str1=%s str2=%s valid=%d\0A\00"
@str = [10 x i8] c"READING:\0A\00"
@str.3 = [7 x i8] c"READ:\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
store i8 83, i8* %6
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 1
store i8 69, i8* %7
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
store i8 67, i8* %8
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
store i8 82, i8* %9
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
store i8 69, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
store i8 84, i8* %11
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 6
store i8 0, i8* %12
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%14 = call i32 @gets(i8* %5)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.3, i64 0, i64 0))
%16 = call i64 @strncmp(i8* %5, i8* %6, i32 8)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6, i32 %18)
%20 = call i32 @exit(i32 0)
unreachable
}