#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int already_sent(char *message) {
  static char old_messages[20][256];
  static int index = 0;
  int i;
  for (i = 0; i < 20; i++) {
    if (!strcmp(message, old_messages[i]))
      return 1;
  }
  strncpy(old_messages[index], message, 256);
  if (index == 20 - 1)
    index = 0;
  else
    index++;
  return 0;
}


x86 assembly (clang, -O0):
<already_sent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1180 <already_sent+0x60>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
lea    0x2ef4(%rip),%rsi
shl    $0x8,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    116d <already_sent+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    11d5 <already_sent+0xb5>
jmp    1172 <already_sent+0x52>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <already_sent+0x13>
movslq 0x42b9(%rip),%rax
lea    0x2eb2(%rip),%rdi
shl    $0x8,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
cmpl   $0x13,0x4296(%rip)
jne    11bf <already_sent+0x9f>
movl   $0x0,0x4286(%rip)
jmp    11ce <already_sent+0xae>
mov    0x427b(%rip),%eax
add    $0x1,%eax
mov    %eax,0x4272(%rip)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<already_sent>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0x2f12(%rip),%rbp
mov    %rbp,%rsi
call   1040 <strcmp@plt>
mov    $0x1,%r14d
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x2ff5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x30de(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x31c7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x32b0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3399(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3482(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x356b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3654(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x373d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3826(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x390f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x39f8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3ae1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3bca(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3cb3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3d9c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3e89(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x3f76(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
lea    0x4063(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1320 <already_sent+0x200>
movslq 0x4150(%rip),%rax
shl    $0x8,%rax
add    %rax,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    0x4133(%rip),%eax
lea    0x1(%rax),%ecx
xor    %r14d,%r14d
cmp    $0x13,%eax
cmove  %r14d,%ecx
mov    %ecx,0x4120(%rip)
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@already_sent.old_messages = internal global [20 x [256 x i8]] zeroinitializer
@already_sent.index = internal global i32 0
define i32 @already_sent(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 %11
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%14 = call i32 @strcmp(i8* %9, i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %8
store i32 1, i32* %2
br label %35
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
%22 = load i32, i32* @already_sent.index
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 %23
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %24, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = call i32 @strncpy(i8* %25, i8* %26, i32 256)
%28 = load i32, i32* @already_sent.index
%29 = icmp eq i32 %28, 19
br i1 %29, label %30, label %31
30: ; preds = %21
store i32 0, i32* @already_sent.index
br label %34
31: ; preds = %21
%32 = load i32, i32* @already_sent.index
%33 = add nsw i32 %32, 1
store i32 %33, i32* @already_sent.index
br label %34
34: ; preds = %31, %30
store i32 0, i32* %2
br label %35
35: ; preds = %34, %16
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@already_sent.old_messages = internal global [20 x [256 x i8]] zeroinitializer
@already_sent.index = internal unnamed_addr global i32 0
define i32 @already_sent(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %70, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 1, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %70, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 2, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %70, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 3, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %70, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 4, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %70, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 5, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %70, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 6, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %70, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 7, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %70, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 8, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %70, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 9, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %70, label %31
31: ; preds = %28
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 10, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %70, label %34
34: ; preds = %31
%35 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 11, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %70, label %37
37: ; preds = %34
%38 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 12, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %70, label %40
40: ; preds = %37
%41 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 13, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %70, label %43
43: ; preds = %40
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 14, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %70, label %46
46: ; preds = %43
%47 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 15, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %70, label %49
49: ; preds = %46
%50 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 16, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %70, label %52
52: ; preds = %49
%53 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 17, i64 0))
%54 = icmp eq i32 %53, 0
br i1 %54, label %70, label %55
55: ; preds = %52
%56 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 18, i64 0))
%57 = icmp eq i32 %56, 0
br i1 %57, label %70, label %58
58: ; preds = %55
%59 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 19, i64 0))
%60 = icmp eq i32 %59, 0
br i1 %60, label %70, label %61
61: ; preds = %58
%62 = load i32, i32* @already_sent.index
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [20 x [256 x i8]], [20 x [256 x i8]]* @already_sent.old_messages, i64 0, i64 %63, i64 0
%65 = tail call i32 @strncpy(i8* %64, i8* %0, i32 256)
%66 = load i32, i32* @already_sent.index
%67 = icmp eq i32 %66, 19
%68 = add nsw i32 %66, 1
%69 = select i1 %67, i32 0, i32 %68
store i32 %69, i32* @already_sent.index
br label %70
70: ; preds = %1, %4, %7, %10, %13, %16, %19, %22, %25, %28, %31, %34, %37, %40, %43, %46, %49, %52, %55, %58, %61
%71 = phi i32 [ 0, %61 ], [ 1, %58 ], [ 1, %55 ], [ 1, %52 ], [ 1, %49 ], [ 1, %46 ], [ 1, %43 ], [ 1, %40 ], [ 1, %37 ], [ 1, %34 ], [ 1, %31 ], [ 1, %28 ], [ 1, %25 ], [ 1, %22 ], [ 1, %19 ], [ 1, %16 ], [ 1, %13 ], [ 1, %10 ], [ 1, %7 ], [ 1, %4 ], [ 1, %1 ]
ret i32 %71
}