#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 */
struct dfa_t {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ accepts_input(struct dfa_t *, int *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(struct dfa_t *);
int /*<<< orphan*/ make_dfa(struct dfa_t **);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read_dfa(struct dfa_t *, int /*<<< orphan*/ *);
int main(int argc, char *argsv[]) {
  struct dfa_t *dfa;
  FILE *fp;
  int input[5] = {0, 1, 1, 1, 1};
  fp = fopen("dfa.txt", "r");
  make_dfa(&dfa);
  read_dfa(dfa, fp);
  if (accepts_input(dfa, input, 5)) {
    puts("divisible by 3");
  } else {
    puts("not divisible by 3");
  }
  fclose(fp);
  free(dfa);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe6e(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    0xe68(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <make_dfa@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <read_dfa@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x5,%edx
call   1080 <accepts_input@plt>
cmp    $0x0,%rax
je     11ff <main+0x8f>
lea    0xe2d(%rip),%rdi
call   1040 <puts@plt>
jmp    120b <main+0x9b>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xe95(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xe7a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe82(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
call   1070 <make_dfa@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <read_dfa@plt>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x5,%edx
call   1080 <accepts_input@plt>
test   %rax,%rax
lea    0xe48(%rip),%rax
lea    0xe45(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.dfa_t = type { i32 }
@__const.main.input = [5 x i32] [i32 0, i32 1, i32 1, i32 1, i32 1]
@.str = [8 x i8] c"dfa.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [15 x i8] c"divisible by 3\00"
@.str.3 = [19 x i8] c"not divisible by 3\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.dfa_t*
%7 = alloca i32*
%8 = alloca [5 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [5 x i32]* %8 to i8*
%10 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %7
%11 = call i32 @make_dfa(%struct.dfa_t** %6)
%12 = load %struct.dfa_t*, %struct.dfa_t** %6
%13 = load i32*, i32** %7
%14 = call i32 @read_dfa(%struct.dfa_t* %12, i32* %13)
%15 = load %struct.dfa_t*, %struct.dfa_t** %6
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%17 = call i64 @accepts_input(%struct.dfa_t* %15, i32* %16, i32 5)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %2
%22 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = load i32*, i32** %7
%25 = call i32 @fclose(i32* %24)
%26 = load %struct.dfa_t*, %struct.dfa_t** %6
%27 = call i32 @free(%struct.dfa_t* %26)
ret i32 0
}

LLVM IR (-O2):
%struct.dfa_t = type { i32 }
@__const.main.input = [5 x i32] [i32 0, i32 1, i32 1, i32 1, i32 1]
@.str = [8 x i8] c"dfa.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [15 x i8] c"divisible by 3\00"
@.str.3 = [19 x i8] c"not divisible by 3\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.dfa_t*
%4 = alloca [5 x i32]
%5 = bitcast %struct.dfa_t** %3 to i8*
%6 = bitcast [5 x i32]* %4 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @make_dfa(%struct.dfa_t** %3)
%9 = load %struct.dfa_t*, %struct.dfa_t** %3
%10 = call i32 @read_dfa(%struct.dfa_t* %9, i32* %7)
%11 = load %struct.dfa_t*, %struct.dfa_t** %3
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%13 = call i64 @accepts_input(%struct.dfa_t* %11, i32* %12, i32 5)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = call i32 @fclose(i32* %7)
%18 = load %struct.dfa_t*, %struct.dfa_t** %3
%19 = call i32 @free(%struct.dfa_t* %18)
ret i32 0
}