#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 *);
int strlen(char *);
int check_filter_error(char *filter_setting) {
  int i;
  if (strlen(filter_setting) != 3) {
    printf("The string has to be long 3 char\n");
    return 1;
  }
  for (i = 0; i < 3; i++) {
    if (filter_setting[i] != '0' && filter_setting[i] != '1') {
      printf("The string has to contain only 0 or 1\n");
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_filter_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
je     1156 <check_filter_error+0x36>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <check_filter_error+0xa3>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11bc <check_filter_error+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
je     11a9 <check_filter_error+0x89>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
je     11a9 <check_filter_error+0x89>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <check_filter_error+0xa3>
jmp    11ae <check_filter_error+0x8e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <check_filter_error+0x3d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_filter_error>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x3,%eax
jne    1155 <check_filter_error+0x35>
mov    (%rbx),%al
and    $0xfe,%al
lea    0xec7(%rip),%rdi
cmp    $0x30,%al
jne    115c <check_filter_error+0x3c>
mov    0x1(%rbx),%al
and    $0xfe,%al
cmp    $0x30,%al
jne    115c <check_filter_error+0x3c>
mov    0x2(%rbx),%cl
and    $0xfe,%cl
xor    %eax,%eax
cmp    $0x30,%cl
jne    115c <check_filter_error+0x3c>
pop    %rbx
ret
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"The string has to be long 3 char\0A\00"
@.str.1 = [39 x i8] c"The string has to contain only 0 or 1\0A\00"
define i32 @check_filter_error(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %37
10: ; preds = %1
store i32 0, i32* %4
br label %11
11: ; preds = %33, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %36
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 48
br i1 %21, label %22, label %32
22: ; preds = %14
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 49
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %37
32: ; preds = %22, %14
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %11
36: ; preds = %11
store i32 0, i32* %2
br label %37
37: ; preds = %36, %30, %8
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@str = [38 x i8] c"The string has to contain only 0 or 1\00"
@str.2 = [33 x i8] c"The string has to be long 3 char\00"
define i32 @check_filter_error(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 3
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = load i8, i8* %0
%6 = and i8 %5, -2
%7 = icmp eq i8 %6, 48
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = and i8 %10, -2
%12 = icmp eq i8 %11, 48
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = load i8, i8* %14
%16 = and i8 %15, -2
%17 = icmp eq i8 %16, 48
br i1 %17, label %21, label %18
18: ; preds = %4, %8, %13, %1
%19 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0), %4 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ 0, %13 ], [ 1, %18 ]
ret i32 %22
}