#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*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int is_variant(char *);
int /*<<< orphan*/ stderr;
int test_variant(void) {
  char **test;
  int i, ret;
  char *input[] = {"normal", " normal", "normal@", "nor mal", "Normal", NULL};
  int result[] = {1, 0, 1, 0, 0};
  test = input;
  i = 0;
  ret = 1;
  while ((*test) != NULL) {
    if (is_variant(*test) != result[i]) {
      fprintf(stderr, "test_variant(): test %d failed with test=\"%s\"\n", i,
              *test);
      ret = 0;
    }
    test++;
    i++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<test_variant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xeb2(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x50(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     121c <test_variant+0xec>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <is_variant@plt>
movslq -0xc(%rbp),%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
je     1202 <test_variant+0xd2>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b4 <test_variant+0x84>
mov    -0x10(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_variant>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xec6(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xeba(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeb6(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xeb2(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xeae(%rip),%rax
mov    %rax,0x20(%rsp)
mov    $0x1,%r15d
lea    0xed4(%rip),%rbp
xor    %ebx,%ebx
mov    0x2e5b(%rip),%r12
lea    0xe93(%rip),%r14
jmp    11a2 <test_variant+0x82>
xchg   %ax,%ax
mov    0x8(%rsp,%rbx,8),%rdi
add    $0x1,%rbx
add    $0x4,%rbp
test   %rdi,%rdi
je     11c3 <test_variant+0xa3>
call   1030 <is_variant@plt>
cmp    0x0(%rbp),%eax
je     1190 <test_variant+0x70>
mov    (%r12),%edi
mov    (%rsp,%rbx,8),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
xor    %r15d,%r15d
jmp    1190 <test_variant+0x70>
mov    %r15d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"normal\00"
@.str.1 = [8 x i8] c" normal\00"
@.str.2 = [8 x i8] c"normal@\00"
@.str.3 = [8 x i8] c"nor mal\00"
@.str.4 = [7 x i8] c"Normal\00"
@__const.test_variant.result = [5 x i32] [i32 1, i32 0, i32 1, i32 0, i32 0]
@stderr = global i32 0
@.str.5 = [47 x i8] c"test_variant(): test %d failed with test=\22%s\22\0A\00"
define i32 @test_variant() {
%1 = alloca i8**
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8*]
%5 = alloca [5 x i32]
%6 = bitcast [6 x i8*]* %4 to i8*
%7 = bitcast i8* %6 to [6 x i8*]*
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %12
%13 = bitcast [5 x i32]* %5 to i8*
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8** %14, i8*** %1
store i32 0, i32* %2
store i32 1, i32* %3
br label %15
15: ; preds = %34, %0
%16 = load i8**, i8*** %1
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load i8**, i8*** %1
%21 = load i8*, i8** %20
%22 = call i32 @is_variant(i8* %21)
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %22, %26
br i1 %27, label %28, label %34
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = load i32, i32* %2
%31 = load i8**, i8*** %1
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %30, i8* %32)
store i32 0, i32* %3
br label %34
34: ; preds = %28, %19
%35 = load i8**, i8*** %1
%36 = getelementptr inbounds i8*, i8** %35, i32 1
store i8** %36, i8*** %1
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %15
39: ; preds = %15
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [7 x i8] c"normal\00"
@.str.1 = [8 x i8] c" normal\00"
@.str.2 = [8 x i8] c"normal@\00"
@.str.3 = [8 x i8] c"nor mal\00"
@.str.4 = [7 x i8] c"Normal\00"
@__const.test_variant.result = [5 x i32] [i32 1, i32 0, i32 1, i32 0, i32 0]
@stderr = global i32 0
@.str.5 = [47 x i8] c"test_variant(): test %d failed with test=\22%s\22\0A\00"
define i32 @test_variant() {
%1 = alloca [6 x i8*]
%2 = bitcast [6 x i8*]* %1 to i8*
%3 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %9
br label %10
10: ; preds = %0, %24
%11 = phi i64 [ 0, %0 ], [ %27, %24 ]
%12 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %0 ], [ %28, %24 ]
%13 = phi i32 [ 1, %0 ], [ %25, %24 ]
%14 = phi i8** [ %5, %0 ], [ %26, %24 ]
%15 = tail call i32 @is_variant(i8* %12)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.test_variant.result, i64 0, i64 %11
%17 = load i32, i32* %16
%18 = icmp eq i32 %15, %17
br i1 %18, label %24, label %19
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %14
%22 = trunc i64 %11 to i32
%23 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %22, i8* %21)
br label %24
24: ; preds = %19, %10
%25 = phi i32 [ 0, %19 ], [ %13, %10 ]
%26 = getelementptr inbounds i8*, i8** %14, i64 1
%27 = add nuw i64 %11, 1
%28 = load i8*, i8** %26
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %10
30: ; preds = %24
ret i32 %25
}