#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*/ StateMachine(char, char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char, char, char, char, char, char, char);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char **argv) {
  char M, i_Q2, i_Q1, i_Q0, o_Q2, o_Q1, o_Q0;
  if (argc != 2 || strlen(argv[1]) != 4) {
    fprintf(stderr, "usage: %s [4-digit state]\n", argv[0]);
    return 1;
  }
  M = argv[1][0] != '0';
  i_Q2 = argv[1][1] != '0';
  i_Q1 = argv[1][2] != '0';
  i_Q0 = argv[1][3] != '0';
  o_Q2 = i_Q2;
  o_Q1 = i_Q1;
  o_Q0 = i_Q0;
  StateMachine(M, &o_Q2, &o_Q1, &o_Q0);
  printf("Input of %d%d%d%d yeilds %d%d%d\n", M, i_Q2, i_Q1, i_Q0, o_Q2, o_Q1,
         o_Q0);
  return 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)
cmpl   $0x2,-0x8(%rbp)
jne    1176 <main+0x36>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
je     119e <main+0x5e>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe73(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1274 <main+0x134>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x30,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x2(%rax),%eax
cmp    $0x30,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x13(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x3(%rax),%eax
cmp    $0x30,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x14(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x13(%rbp),%al
mov    %al,-0x16(%rbp)
mov    -0x14(%rbp),%al
mov    %al,-0x17(%rbp)
lea    -0x15(%rbp),%rsi
lea    -0x16(%rbp),%rdx
lea    -0x17(%rbp),%rcx
movsbl -0x11(%rbp),%edi
call   1030 <StateMachine@plt>
mov    -0x11(%rbp),%sil
mov    -0x12(%rbp),%dl
mov    -0x13(%rbp),%cl
mov    -0x14(%rbp),%r8b
mov    -0x15(%rbp),%r9b
mov    -0x16(%rbp),%al
lea    0xdd3(%rip),%rdi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
movsbl %al,%eax
mov    %eax,(%rsp)
movsbl -0x17(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11ec <main+0xac>
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    11ec <main+0xac>
mov    0x8(%rbx),%rax
xor    %ebx,%ebx
cmpb   $0x30,(%rax)
setne  %bl
xor    %r14d,%r14d
cmpb   $0x30,0x1(%rax)
setne  %r14b
mov    0x2(%rax),%cl
mov    0x3(%rax),%al
setne  0x7(%rsp)
xor    %r15d,%r15d
cmp    $0x30,%cl
setne  0x6(%rsp)
setne  %r15b
xor    %ebp,%ebp
cmp    $0x30,%al
setne  %bpl
setne  0x5(%rsp)
lea    0x7(%rsp),%rsi
lea    0x6(%rsp),%rdx
lea    0x5(%rsp),%rcx
mov    %ebx,%edi
call   1030 <StateMachine@plt>
movsbl 0x7(%rsp),%r9d
movsbl 0x6(%rsp),%r10d
movsbl 0x5(%rsp),%eax
lea    0xe4a(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
push   %rax
push   %r10
call   1050 <printf@plt>
add    $0x10,%rsp
xor    %eax,%eax
jmp    1209 <main+0xc9>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe01(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s [4-digit state]\0A\00"
@.str.1 = [33 x i8] c"Input of %d%d%d%d yeilds %d%d%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
%20 = icmp ne i32 %19, 4
br i1 %20, label %21, label %27
21: ; preds = %15, %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %77
27: ; preds = %15
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 48
%35 = zext i1 %34 to i32
%36 = trunc i32 %35 to i8
store i8 %36, i8* %6
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 48
%44 = zext i1 %43 to i32
%45 = trunc i32 %44 to i8
store i8 %45, i8* %7
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 48
%53 = zext i1 %52 to i32
%54 = trunc i32 %53 to i8
store i8 %54, i8* %8
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 3
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 48
%62 = zext i1 %61 to i32
%63 = trunc i32 %62 to i8
store i8 %63, i8* %9
%64 = load i8, i8* %7
store i8 %64, i8* %10
%65 = load i8, i8* %8
store i8 %65, i8* %11
%66 = load i8, i8* %9
store i8 %66, i8* %12
%67 = load i8, i8* %6
%68 = call i32 @StateMachine(i8 signext %67, i8* %10, i8* %11, i8* %12)
%69 = load i8, i8* %6
%70 = load i8, i8* %7
%71 = load i8, i8* %8
%72 = load i8, i8* %9
%73 = load i8, i8* %10
%74 = load i8, i8* %11
%75 = load i8, i8* %12
%76 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8 signext %69, i8 signext %70, i8 signext %71, i8 signext %72, i8 signext %73, i8 signext %74, i8 signext %75)
store i32 0, i32* %3
br label %77
77: ; preds = %27, %21
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s [4-digit state]\0A\00"
@.str.1 = [33 x i8] c"Input of %d%d%d%d yeilds %d%d%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = icmp eq i32 %0, 2
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 4
br i1 %11, label %16, label %12
12: ; preds = %7, %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %38
16: ; preds = %7
%17 = load i8*, i8** %8
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 48
%20 = zext i1 %19 to i8
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 48
%24 = zext i1 %23 to i8
%25 = getelementptr inbounds i8, i8* %17, i64 2
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 48
%28 = zext i1 %27 to i8
%29 = getelementptr inbounds i8, i8* %17, i64 3
%30 = load i8, i8* %29
%31 = icmp ne i8 %30, 48
%32 = zext i1 %31 to i8
store i8 %24, i8* %3
store i8 %28, i8* %4
store i8 %32, i8* %5
%33 = call i32 @StateMachine(i8 signext %20, i8* %3, i8* %4, i8* %5)
%34 = load i8, i8* %3
%35 = load i8, i8* %4
%36 = load i8, i8* %5
%37 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8 signext %20, i8 signext %24, i8 signext %28, i8 signext %32, i8 signext %34, i8 signext %35, i8 signext %36)
br label %38
38: ; preds = %16, %12
%39 = phi i32 [ 1, %12 ], [ 0, %16 ]
ret i32 %39
}