#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*/ interrupt(int, int, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ neededSectors(int);
void createCommand(char *args[]) {
  char buffer[(32 - 6) * 512];
  char line[256];
  int charCount = 0;
  int q;
  while (1) {
    interrupt(0x21, 0, "> ", 0, 0);
    interrupt(0x21, 1, line, 0, 0);
    if (line[0] == '\r') {
      buffer[charCount] = '\0';
      charCount++;
      break;
    }
    q = 0;
    while (line[q] != '\0') {
      buffer[charCount] = line[q];
      charCount++;
      q++;
    }
  }
  interrupt(0x21, 0x8, args[1], buffer, neededSectors(charCount));
  return;
}


x86 assembly (clang, -O0):
<createCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3530,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x3514(%rbp)
mov    $0x21,%edi
xor    %r8d,%r8d
lea    0xeb8(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%esi
call   1040 <interrupt@plt>
lea    -0x3510(%rbp),%rdx
mov    $0x21,%edi
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
call   1040 <interrupt@plt>
movsbl -0x3510(%rbp),%eax
cmp    $0xd,%eax
jne    11a4 <createCommand+0x84>
movslq -0x3514(%rbp),%rax
movb   $0x0,-0x3410(%rbp,%rax,1)
mov    -0x3514(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3514(%rbp)
jmp    120a <createCommand+0xea>
movl   $0x0,-0x3518(%rbp)
movslq -0x3518(%rbp),%rax
movsbl -0x3510(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1205 <createCommand+0xe5>
movslq -0x3518(%rbp),%rax
mov    -0x3510(%rbp,%rax,1),%cl
movslq -0x3514(%rbp),%rax
mov    %cl,-0x3410(%rbp,%rax,1)
mov    -0x3514(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3514(%rbp)
mov    -0x3518(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3518(%rbp)
jmp    11ae <createCommand+0x8e>
jmp    1139 <createCommand+0x19>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x3528(%rbp)
lea    -0x3410(%rbp),%rax
mov    %rax,-0x3520(%rbp)
mov    -0x3514(%rbp),%edi
call   1030 <neededSectors@plt>
mov    -0x3528(%rbp),%rdx
mov    -0x3520(%rbp),%rcx
mov    %eax,%r8d
mov    $0x21,%edi
mov    $0x8,%esi
call   1040 <interrupt@plt>
add    $0x3530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createCommand>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3508,%rsp
mov    %rdi,%r14
lea    0xec8(%rip),%rdx
xor    %ebx,%ebx
mov    $0x21,%edi
xor    %esi,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <interrupt@plt>
mov    %rsp,%rdx
mov    $0x21,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <interrupt@plt>
mov    (%rsp),%al
cmp    $0xd,%al
jne    11ac <createCommand+0x8c>
movslq %ebx,%rdi
movb   $0x0,0x100(%rsp,%rdi,1)
add    $0x1,%edi
mov    0x8(%r14),%rbx
call   1030 <neededSectors@plt>
lea    0x100(%rsp),%rcx
mov    $0x21,%edi
mov    $0x8,%esi
mov    %rbx,%rdx
mov    %eax,%r8d
call   1040 <interrupt@plt>
add    $0x3508,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %ebx,%ebx
lea    0xe4b(%rip),%r15
mov    %rsp,%r12
jmp    11f6 <createCommand+0xd6>
nopw   0x0(%rax,%rax,1)
mov    $0x21,%edi
xor    %esi,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <interrupt@plt>
mov    $0x21,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <interrupt@plt>
mov    (%rsp),%al
cmp    $0xd,%al
je     1169 <createCommand+0x49>
test   %al,%al
je     11c0 <createCommand+0xa0>
movslq %ebx,%rcx
lea    (%rsp,%rcx,1),%rdx
add    $0x100,%rdx
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rdx,%rcx,1)
movzbl 0x1(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1210 <createCommand+0xf0>
add    %ecx,%ebx
jmp    11c0 <createCommand+0xa0>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
define void @createCommand(i8** %0) {
%2 = alloca i8**
%3 = alloca [13312 x i8]
%4 = alloca [256 x i8]
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %5
br label %7
7: ; preds = %1, %41
%8 = call i32 @interrupt(i32 33, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null, i32 0)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = call i32 @interrupt(i32 33, i32 1, i8* %9, i8* null, i32 0)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 13
br i1 %14, label %15, label %21
15: ; preds = %7
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [13312 x i8], [13312 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %42
21: ; preds = %7
store i32 0, i32* %6
br label %22
22: ; preds = %29, %21
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %22
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [13312 x i8], [13312 x i8]* %3, i64 0, i64 %35
store i8 %33, i8* %36
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %22
41: ; preds = %22
br label %7
42: ; preds = %15
%43 = load i8**, i8*** %2
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = getelementptr inbounds [13312 x i8], [13312 x i8]* %3, i64 0, i64 0
%47 = load i32, i32* %5
%48 = call i32 @neededSectors(i32 %47)
%49 = call i32 @interrupt(i32 33, i32 8, i8* %45, i8* %46, i32 %48)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
define void @createCommand(i8** nocapture %0) {
%2 = alloca [13312 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [13312 x i8], [13312 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @interrupt(i32 33, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null, i32 0)
%7 = call i32 @interrupt(i32 33, i32 1, i8* %5, i8* null, i32 0)
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 13
br i1 %9, label %24, label %18
10: ; preds = %33
%11 = trunc i64 %38 to i32
br label %12
12: ; preds = %10, %18
%13 = phi i32 [ %20, %18 ], [ %11, %10 ]
%14 = call i32 @interrupt(i32 33, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null, i32 0)
%15 = call i32 @interrupt(i32 33, i32 1, i8* %5, i8* null, i32 0)
%16 = load i8, i8* %5
%17 = icmp eq i8 %16, 13
br i1 %17, label %24, label %18
18: ; preds = %1, %12
%19 = phi i8 [ %16, %12 ], [ %8, %1 ]
%20 = phi i32 [ %13, %12 ], [ 0, %1 ]
%21 = icmp eq i8 %19, 0
br i1 %21, label %12, label %22
22: ; preds = %18
%23 = sext i32 %20 to i64
br label %33
24: ; preds = %12, %1
%25 = phi i32 [ 0, %1 ], [ %13, %12 ]
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [13312 x i8], [13312 x i8]* %2, i64 0, i64 %26
store i8 0, i8* %27
%28 = add nsw i32 %25, 1
%29 = getelementptr inbounds i8*, i8** %0, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @neededSectors(i32 %28)
%32 = call i32 @interrupt(i32 33, i32 8, i8* %30, i8* %4, i32 %31)
ret void
33: ; preds = %22, %33
%34 = phi i64 [ %23, %22 ], [ %38, %33 ]
%35 = phi i64 [ 0, %22 ], [ %39, %33 ]
%36 = phi i8 [ %19, %22 ], [ %41, %33 ]
%37 = getelementptr inbounds [13312 x i8], [13312 x i8]* %2, i64 0, i64 %34
store i8 %36, i8* %37
%38 = add i64 %34, 1
%39 = add nuw nsw i64 %35, 1
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %10, label %33
}