#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_asm(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ana_asm(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ dcr_asm(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ inr_asm(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mvi_asm(char *, char *, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ sub_asm(char *, int /*<<< orphan*/ *);
void assemble_line(FILE *file, char *line) {
  char *buffer = strtok(line, ", ");
  char *inst[3] = {NULL, NULL, NULL};
  int i = 0;
  while (buffer != NULL) {
    inst[i++] = buffer;
    buffer = strtok(NULL, ", ");
  }
  if (strcmp(inst[0], "mvi") == 0) {
    mvi_asm(inst[1], inst[2], file);
  } else if (strcmp(inst[0], "add") == 0) {
    add_asm(inst[1], file);
  } else if (strcmp(inst[0], "sub") == 0) {
    sub_asm(inst[1], file);
  } else if (strcmp(inst[0], "dcr") == 0) {
    dcr_asm(inst[1], file);
  } else if (strcmp(inst[0], "inr") == 0) {
    inr_asm(inst[1], file);
  } else if (strcmp(inst[0], "ana") == 0) {
    ana_asm(inst[1], file);
  } else {
  }
  free(buffer);
}


x86 assembly (clang, -O0):
<assemble_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1215 <assemble_line+0x75>
mov    -0x18(%rbp),%rcx
mov    -0x34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
cltq
mov    %rcx,-0x30(%rbp,%rax,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf9(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11db <assemble_line+0x3b>
mov    -0x30(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <assemble_line+0xa5>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1090 <mvi_asm@plt>
jmp    133f <assemble_line+0x19f>
mov    -0x30(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1271 <assemble_line+0xd1>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <add_asm@plt>
jmp    133a <assemble_line+0x19a>
mov    -0x30(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    129d <assemble_line+0xfd>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <sub_asm@plt>
jmp    1335 <assemble_line+0x195>
mov    -0x30(%rbp),%rdi
lea    0xd67(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12c9 <assemble_line+0x129>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <dcr_asm@plt>
jmp    1330 <assemble_line+0x190>
mov    -0x30(%rbp),%rdi
lea    0xd3f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12f5 <assemble_line+0x155>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10b0 <inr_asm@plt>
jmp    132b <assemble_line+0x18b>
mov    -0x30(%rbp),%rdi
lea    0xd17(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1321 <assemble_line+0x181>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10c0 <ana_asm@plt>
jmp    1326 <assemble_line+0x186>
jmp    1326 <assemble_line+0x186>
jmp    132b <assemble_line+0x18b>
jmp    1330 <assemble_line+0x190>
jmp    1335 <assemble_line+0x195>
jmp    133a <assemble_line+0x19a>
jmp    133f <assemble_line+0x19f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assemble_line>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe5a(%rip),%rsi
mov    %rax,%rdi
call   1090 <strtok@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
test   %rax,%rax
je     11ec <assemble_line+0x5c>
mov    %rsp,%rbx
lea    0xe33(%rip),%r15
nopl   (%rax)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1090 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11d0 <assemble_line+0x40>
mov    (%rsp),%rbx
jmp    11ee <assemble_line+0x5e>
xor    %ebx,%ebx
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1275 <assemble_line+0xe5>
lea    0xdfe(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1289 <assemble_line+0xf9>
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1298 <assemble_line+0x108>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a7 <assemble_line+0x117>
lea    0xdce(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12b6 <assemble_line+0x126>
lea    0xdbe(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   10b0 <ana_asm@plt>
jmp    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1080 <mvi_asm@plt>
jmp    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1050 <add_asm@plt>
jmp    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1060 <sub_asm@plt>
jmp    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1040 <dcr_asm@plt>
jmp    12c3 <assemble_line+0x133>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   10a0 <inr_asm@plt>
xor    %edi,%edi
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c", \00"
@.str.1 = [4 x i8] c"mvi\00"
@.str.2 = [4 x i8] c"add\00"
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"dcr\00"
@.str.5 = [4 x i8] c"inr\00"
@.str.6 = [4 x i8] c"ana\00"
define void @assemble_line(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [3 x i8*]
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %5
%10 = bitcast [3 x i8*]* %6 to i8*
store i32 0, i32* %7
br label %11
11: ; preds = %14, %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 %18
store i8* %15, i8** %19
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %5
br label %11
21: ; preds = %11
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 2
%30 = load i8*, i8** %29
%31 = load i32*, i32** %3
%32 = call i32 @mvi_asm(i8* %28, i8* %30, i32* %31)
br label %89
33: ; preds = %21
%34 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%40 = load i8*, i8** %39
%41 = load i32*, i32** %3
%42 = call i32 @add_asm(i8* %40, i32* %41)
br label %88
43: ; preds = %33
%44 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%50 = load i8*, i8** %49
%51 = load i32*, i32** %3
%52 = call i32 @sub_asm(i8* %50, i32* %51)
br label %87
53: ; preds = %43
%54 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %53
%59 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%60 = load i8*, i8** %59
%61 = load i32*, i32** %3
%62 = call i32 @dcr_asm(i8* %60, i32* %61)
br label %86
63: ; preds = %53
%64 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%65 = load i8*, i8** %64
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%70 = load i8*, i8** %69
%71 = load i32*, i32** %3
%72 = call i32 @inr_asm(i8* %70, i32* %71)
br label %85
73: ; preds = %63
%74 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
%75 = load i8*, i8** %74
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %73
%79 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 1
%80 = load i8*, i8** %79
%81 = load i32*, i32** %3
%82 = call i32 @ana_asm(i8* %80, i32* %81)
br label %84
83: ; preds = %73
br label %84
84: ; preds = %83, %78
br label %85
85: ; preds = %84, %68
br label %86
86: ; preds = %85, %58
br label %87
87: ; preds = %86, %48
br label %88
88: ; preds = %87, %38
br label %89
89: ; preds = %88, %26
%90 = load i8*, i8** %5
%91 = call i32 @free(i8* %90)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c", \00"
@.str.1 = [4 x i8] c"mvi\00"
@.str.2 = [4 x i8] c"add\00"
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"dcr\00"
@.str.5 = [4 x i8] c"inr\00"
@.str.6 = [4 x i8] c"ana\00"
define void @assemble_line(i32* %0, i8* %1) {
%3 = alloca [3 x i8*]
%4 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [3 x i8*]* %3 to i8*
%6 = icmp eq i8* %4, null
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %10, %7 ], [ 0, %2 ]
%9 = phi i8* [ %12, %7 ], [ %4, %2 ]
%10 = add nuw i64 %8, 1
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 %8
store i8* %9, i8** %11
%12 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%16 = load i8*, i8** %15
br label %17
17: ; preds = %14, %2
%18 = phi i8* [ %16, %14 ], [ null, %2 ]
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @mvi_asm(i8* %23, i8* %25, i32* %0)
br label %62
27: ; preds = %17
%28 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%32 = load i8*, i8** %31
%33 = tail call i32 @add_asm(i8* %32, i32* %0)
br label %62
34: ; preds = %27
%35 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%39 = load i8*, i8** %38
%40 = tail call i32 @sub_asm(i8* %39, i32* %0)
br label %62
41: ; preds = %34
%42 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%46 = load i8*, i8** %45
%47 = tail call i32 @dcr_asm(i8* %46, i32* %0)
br label %62
48: ; preds = %41
%49 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%53 = load i8*, i8** %52
%54 = tail call i32 @inr_asm(i8* %53, i32* %0)
br label %62
55: ; preds = %48
%56 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
%60 = load i8*, i8** %59
%61 = tail call i32 @ana_asm(i8* %60, i32* %0)
br label %62
62: ; preds = %30, %44, %58, %55, %51, %37, %21
%63 = tail call i32 @free(i8* null)
ret void
}