#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int process_line(char *, int /*<<< orphan*/ *);
char *read_line(size_t *, char *, size_t);
void assembly(size_t size, char *data, FILE *output) {
  size_t pos;
  char *line;
  int res;
  pos = 0;
  while (pos < size) {
    line = read_line(&pos, data, size);
    if (line == NULL) {
      break;
    }
    res = process_line(line, output);
    if (res == -1) {
      printf("syntax error in: %s\n", line);
    }
    free(line);
  }
}


x86 assembly (clang, -O0):
<assembly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11c7 <assembly+0x87>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    -0x20(%rbp),%rdi
call   1050 <read_line@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118f <assembly+0x4f>
jmp    11c7 <assembly+0x87>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <process_line@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11b9 <assembly+0x79>
mov    -0x28(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    115c <assembly+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assembly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
test   %rdi,%rdi
je     11b1 <assembly+0x71>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%r12
lea    0xe95(%rip),%r13
jmp    117e <assembly+0x3e>
nopl   (%rax)
mov    %rbp,%rdi
call   1030 <free@plt>
cmp    %rbx,(%rsp)
jae    11b1 <assembly+0x71>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <read_line@plt>
test   %rax,%rax
je     11b1 <assembly+0x71>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <process_line@plt>
cmp    $0xffffffff,%eax
jne    1170 <assembly+0x30>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
jmp    1170 <assembly+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"syntax error in: %s\0A\00"
define void @assembly(i64 %0, i8* %1, i32* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i64 0, i64* %7
br label %10
10: ; preds = %30, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %4
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i64, i64* %4
%17 = call i8* @read_line(i64* %7, i8* %15, i64 %16)
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %14
br label %33
21: ; preds = %14
%22 = load i8*, i8** %8
%23 = load i32*, i32** %6
%24 = call i32 @process_line(i8* %22, i32* %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i8*, i8** %8
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %21
%31 = load i8*, i8** %8
%32 = call i32 @free(i8* %31)
br label %10
33: ; preds = %20, %10
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"syntax error in: %s\0A\00"
define void @assembly(i64 %0, i8* %1, i32* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%6 = icmp eq i64 %0, 0
br i1 %6, label %19, label %7
7: ; preds = %3, %15
%8 = call i8* @read_line(i64* %4, i8* %1, i64 %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = call i32 @process_line(i8* %8, i32* %2)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %15
15: ; preds = %13, %10
%16 = call i32 @free(i8* %8)
%17 = load i64, i64* %4
%18 = icmp ult i64 %17, %0
br i1 %18, label %7, label %19
19: ; preds = %15, %7, %3
ret void
}