#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 */
typedef int /*<<< orphan*/ validkey;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int valid_key(char *key) {
  char validkey[11] = "321-123-231";
  int i, size;
  size = 0;
  for (i = 0; key[i]; i++) {
    size++;
  }
  if (size > 11) {
    printf("%s", "\tNot valid!");
    return 0;
  }
  for (i = 0; i < sizeof(validkey); i++) {
    if (validkey[i] != key[i]) {
      printf("\t%s\n", "\tNot valid!");
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xeda(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xed2(%rip),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1172 <valid_key+0x62>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1149 <valid_key+0x39>
cmpl   $0xb,-0x24(%rbp)
jle    119b <valid_key+0x8b>
lea    0xe88(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <valid_key+0xf6>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    $0xb,%rax
jae    11ff <valid_key+0xef>
movslq -0x20(%rbp),%rax
movsbl -0x1b(%rbp,%rax,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11ec <valid_key+0xdc>
lea    0xe46(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <valid_key+0xf6>
jmp    11f1 <valid_key+0xe1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a2 <valid_key+0x92>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_key>:
push   %rax
mov    %rdi,%rcx
mov    (%rdi),%al
lea    0xef2(%rip),%rdi
test   %al,%al
je     118e <valid_key+0x7e>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,0x1(%rcx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1130 <valid_key+0x20>
cmp    $0xb,%edx
jbe    1149 <valid_key+0x39>
lea    0xeb9(%rip),%rdi
jmp    118e <valid_key+0x7e>
cmp    $0x33,%al
jne    118e <valid_key+0x7e>
cmpb   $0x32,0x1(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x31,0x2(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x2d,0x3(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x31,0x4(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x32,0x5(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x33,0x6(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x2d,0x7(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x32,0x8(%rcx)
jne    118e <valid_key+0x7e>
cmpb   $0x33,0x9(%rcx)
jne    118e <valid_key+0x7e>
mov    $0x1,%eax
cmpb   $0x31,0xa(%rcx)
je     119c <valid_key+0x8c>
lea    0xe6e(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.valid_key.validkey = [11 x i8] c"321-123-231"
@.str = [3 x i8] c"%s\00"
@.str.1 = [12 x i8] c"\09Not valid!\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
define i32 @valid_key(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [11 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [11 x i8]* %4 to i8*
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %18, %1
%9 = load i8*, i8** %3
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %8
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %18
18: ; preds = %15
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 11
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %51
26: ; preds = %21
store i32 0, i32* %5
br label %27
27: ; preds = %47, %26
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = icmp ult i64 %29, 11
br i1 %30, label %31, label %50
31: ; preds = %27
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = load i8*, i8** %3
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %36, %42
br i1 %43, label %44, label %46
44: ; preds = %31
%45 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %51
46: ; preds = %31
br label %47
47: ; preds = %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %27
50: ; preds = %27
store i32 1, i32* %2
br label %51
51: ; preds = %50, %44, %24
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [12 x i8] c"\09Not valid!\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
define i32 @valid_key(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %55, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %6, %4 ], [ 0, %1 ]
%6 = add nuw nsw i64 %5, 1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %4
10: ; preds = %4
%11 = trunc i64 %6 to i32
%12 = icmp ugt i32 %11, 11
br i1 %12, label %55, label %13
13: ; preds = %10
%14 = icmp eq i8 %2, 51
br i1 %14, label %15, label %55
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %0, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 50
br i1 %18, label %19, label %55
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %0, i64 2
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 49
br i1 %22, label %23, label %55
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %0, i64 3
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 45
br i1 %26, label %27, label %55
27: ; preds = %23
%28 = getelementptr inbounds i8, i8* %0, i64 4
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 49
br i1 %30, label %31, label %55
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %0, i64 5
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 50
br i1 %34, label %35, label %55
35: ; preds = %31
%36 = getelementptr inbounds i8, i8* %0, i64 6
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 51
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = getelementptr inbounds i8, i8* %0, i64 7
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 45
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %0, i64 8
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 50
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = getelementptr inbounds i8, i8* %0, i64 9
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 51
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = getelementptr inbounds i8, i8* %0, i64 10
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 49
br i1 %54, label %58, label %55
55: ; preds = %13, %15, %19, %23, %27, %31, %35, %39, %43, %47, %51, %1, %10
%56 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %51 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %47 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %43 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %39 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %35 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %31 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %27 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %23 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %19 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %13 ]
%57 = tail call i32 @printf(i8* %56, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %55, %51
%59 = phi i32 [ 1, %51 ], [ 0, %55 ]
ret i32 %59
}