#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*/ launchProgram(int);
scalar_t__ mod(int, int);
int /*<<< orphan*/ printString(char *);
int /*<<< orphan*/ putInMemory(int, unsigned int, char);
int readFile(char *, char *);
void executeProgram(char *name, int segment) {
  char buffer[13312];
  char errorMsg[35];
  int result;
  unsigned int i;
  if (mod(segment, 0x1000) != 0) {
    errorMsg[0] = 'S';
    errorMsg[1] = 'e';
    errorMsg[2] = 'g';
    errorMsg[3] = 'm';
    errorMsg[4] = 'e';
    errorMsg[5] = 'n';
    errorMsg[6] = 't';
    errorMsg[7] = ' ';
    errorMsg[8] = 'n';
    errorMsg[9] = 'o';
    errorMsg[10] = 't';
    errorMsg[11] = ' ';
    errorMsg[12] = 'a';
    errorMsg[13] = ' ';
    errorMsg[14] = 'm';
    errorMsg[15] = 'u';
    errorMsg[16] = 'l';
    errorMsg[17] = 't';
    errorMsg[18] = 'i';
    errorMsg[19] = 'p';
    errorMsg[20] = 'l';
    errorMsg[21] = 'e';
    errorMsg[22] = ' ';
    errorMsg[23] = 'o';
    errorMsg[24] = 'f';
    errorMsg[25] = ' ';
    errorMsg[26] = '0';
    errorMsg[27] = 'x';
    errorMsg[28] = '1';
    errorMsg[29] = '0';
    errorMsg[30] = '0';
    errorMsg[31] = '0';
    errorMsg[32] = '\r';
    errorMsg[33] = '\n';
    errorMsg[34] = '\0';
    printString(errorMsg);
    return;
  } else if (segment == 0 || segment == 0x1000 || segment > 0xA000) {
    errorMsg[0] = 'I';
    errorMsg[1] = 'l';
    errorMsg[2] = 'l';
    errorMsg[3] = 'e';
    errorMsg[4] = 'g';
    errorMsg[5] = 'a';
    errorMsg[6] = 'l';
    errorMsg[7] = ' ';
    errorMsg[8] = 's';
    errorMsg[9] = 'e';
    errorMsg[10] = 'g';
    errorMsg[11] = 'm';
    errorMsg[12] = 'e';
    errorMsg[13] = 'n';
    errorMsg[14] = 't';
    errorMsg[15] = '\0';
    printString(errorMsg);
    return;
  }
  result = readFile(name, buffer);
  if (result == 0) {
    for (i = 0; i < 13312; i++) {
      putInMemory(segment, i, buffer[i]);
    }
    launchProgram(segment);
  }
}


x86 assembly (clang, -O0):
<executeProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3450,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1000,%esi
call   1030 <mod@plt>
cmp    $0x0,%rax
je     127f <executeProgram+0x12f>
movb   $0x53,-0x3440(%rbp)
movb   $0x65,-0x343f(%rbp)
movb   $0x67,-0x343e(%rbp)
movb   $0x6d,-0x343d(%rbp)
movb   $0x65,-0x343c(%rbp)
movb   $0x6e,-0x343b(%rbp)
movb   $0x74,-0x343a(%rbp)
movb   $0x20,-0x3439(%rbp)
movb   $0x6e,-0x3438(%rbp)
movb   $0x6f,-0x3437(%rbp)
movb   $0x74,-0x3436(%rbp)
movb   $0x20,-0x3435(%rbp)
movb   $0x61,-0x3434(%rbp)
movb   $0x20,-0x3433(%rbp)
movb   $0x6d,-0x3432(%rbp)
movb   $0x75,-0x3431(%rbp)
movb   $0x6c,-0x3430(%rbp)
movb   $0x74,-0x342f(%rbp)
movb   $0x69,-0x342e(%rbp)
movb   $0x70,-0x342d(%rbp)
movb   $0x6c,-0x342c(%rbp)
movb   $0x65,-0x342b(%rbp)
movb   $0x20,-0x342a(%rbp)
movb   $0x6f,-0x3429(%rbp)
movb   $0x66,-0x3428(%rbp)
movb   $0x20,-0x3427(%rbp)
movb   $0x30,-0x3426(%rbp)
movb   $0x78,-0x3425(%rbp)
movb   $0x31,-0x3424(%rbp)
movb   $0x30,-0x3423(%rbp)
movb   $0x30,-0x3422(%rbp)
movb   $0x30,-0x3421(%rbp)
movb   $0xd,-0x3420(%rbp)
movb   $0xa,-0x341f(%rbp)
movb   $0x0,-0x341e(%rbp)
lea    -0x3440(%rbp),%rdi
call   1050 <printString@plt>
jmp    139e <executeProgram+0x24e>
cmpl   $0x0,-0xc(%rbp)
je     12a3 <executeProgram+0x153>
cmpl   $0x1000,-0xc(%rbp)
je     12a3 <executeProgram+0x153>
cmpl   $0xa000,-0xc(%rbp)
jle    1324 <executeProgram+0x1d4>
movb   $0x49,-0x3440(%rbp)
movb   $0x6c,-0x343f(%rbp)
movb   $0x6c,-0x343e(%rbp)
movb   $0x65,-0x343d(%rbp)
movb   $0x67,-0x343c(%rbp)
movb   $0x61,-0x343b(%rbp)
movb   $0x6c,-0x343a(%rbp)
movb   $0x20,-0x3439(%rbp)
movb   $0x73,-0x3438(%rbp)
movb   $0x65,-0x3437(%rbp)
movb   $0x67,-0x3436(%rbp)
movb   $0x6d,-0x3435(%rbp)
movb   $0x65,-0x3434(%rbp)
movb   $0x6e,-0x3433(%rbp)
movb   $0x74,-0x3432(%rbp)
movb   $0x0,-0x3431(%rbp)
lea    -0x3440(%rbp),%rdi
call   1050 <printString@plt>
jmp    139e <executeProgram+0x24e>
jmp    1329 <executeProgram+0x1d9>
mov    -0x8(%rbp),%rdi
lea    -0x3410(%rbp),%rsi
call   1070 <readFile@plt>
mov    %eax,-0x3444(%rbp)
cmpl   $0x0,-0x3444(%rbp)
jne    139e <executeProgram+0x24e>
movl   $0x0,-0x3448(%rbp)
cmpl   $0x3400,-0x3448(%rbp)
jae    1396 <executeProgram+0x246>
mov    -0xc(%rbp),%edi
mov    -0x3448(%rbp),%esi
mov    -0x3448(%rbp),%eax
movsbl -0x3410(%rbp,%rax,1),%edx
ff
call   1040 <putInMemory@plt>
mov    -0x3448(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3448(%rbp)
jmp    1356 <executeProgram+0x206>
mov    -0xc(%rbp),%edi
call   1060 <launchProgram@plt>
add    $0x3450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeProgram>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3400,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
mov    $0x1000,%esi
call   1030 <mod@plt>
test   %rax,%rax
je     1196 <executeProgram+0x46>
movaps 0xe88(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0xa0d,0x20(%rsp)
movb   $0x0,0x22(%rsp)
jmp    11ee <executeProgram+0x9e>
cmp    $0xa000,%ebp
jg     11e3 <executeProgram+0x93>
mov    %ebp,%eax
and    $0xffffefff,%eax
je     11e3 <executeProgram+0x93>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1070 <readFile@plt>
test   %eax,%eax
jne    11f6 <executeProgram+0xa6>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edx
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <putInMemory@plt>
add    $0x1,%rbx
cmp    $0x3400,%rbx
jne    11c0 <executeProgram+0x70>
mov    %ebp,%edi
call   1060 <launchProgram@plt>
jmp    11f6 <executeProgram+0xa6>
movaps 0xe36(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1050 <printString@plt>
add    $0x3400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @executeProgram(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [13312 x i8]
%6 = alloca [35 x i8]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = call i64 @mod(i32 %9, i32 4096)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %50
12: ; preds = %2
%13 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
store i8 83, i8* %13
%14 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 1
store i8 101, i8* %14
%15 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 2
store i8 103, i8* %15
%16 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 3
store i8 109, i8* %16
%17 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 4
store i8 101, i8* %17
%18 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 5
store i8 110, i8* %18
%19 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 6
store i8 116, i8* %19
%20 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 7
store i8 32, i8* %20
%21 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 8
store i8 110, i8* %21
%22 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 9
store i8 111, i8* %22
%23 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 10
store i8 116, i8* %23
%24 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 11
store i8 32, i8* %24
%25 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 12
store i8 97, i8* %25
%26 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 13
store i8 32, i8* %26
%27 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 14
store i8 109, i8* %27
%28 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 15
store i8 117, i8* %28
%29 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 16
store i8 108, i8* %29
%30 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 17
store i8 116, i8* %30
%31 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 18
store i8 105, i8* %31
%32 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 19
store i8 112, i8* %32
%33 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 20
store i8 108, i8* %33
%34 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 21
store i8 101, i8* %34
%35 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 22
store i8 32, i8* %35
%36 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 23
store i8 111, i8* %36
%37 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 24
store i8 102, i8* %37
%38 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 25
store i8 32, i8* %38
%39 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 26
store i8 48, i8* %39
%40 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 27
store i8 120, i8* %40
%41 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 28
store i8 49, i8* %41
%42 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 29
store i8 48, i8* %42
%43 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 30
store i8 48, i8* %43
%44 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 31
store i8 48, i8* %44
%45 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 32
store i8 13, i8* %45
%46 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 33
store i8 10, i8* %46
%47 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 34
store i8 0, i8* %47
%48 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%49 = call i32 @printString(i8* %48)
br label %103
50: ; preds = %2
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %50
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 4096
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i32, i32* %4
%58 = icmp sgt i32 %57, 40960
br i1 %58, label %59, label %78
59: ; preds = %56, %53, %50
%60 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
store i8 73, i8* %60
%61 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 1
store i8 108, i8* %61
%62 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 2
store i8 108, i8* %62
%63 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 3
store i8 101, i8* %63
%64 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 4
store i8 103, i8* %64
%65 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 5
store i8 97, i8* %65
%66 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 6
store i8 108, i8* %66
%67 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 7
store i8 32, i8* %67
%68 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 8
store i8 115, i8* %68
%69 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 9
store i8 101, i8* %69
%70 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 10
store i8 103, i8* %70
%71 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 11
store i8 109, i8* %71
%72 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 12
store i8 101, i8* %72
%73 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 13
store i8 110, i8* %73
%74 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 14
store i8 116, i8* %74
%75 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 15
store i8 0, i8* %75
%76 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%77 = call i32 @printString(i8* %76)
br label %103
78: ; preds = %56
br label %79
79: ; preds = %78
%80 = load i8*, i8** %3
%81 = getelementptr inbounds [13312 x i8], [13312 x i8]* %5, i64 0, i64 0
%82 = call i32 @readFile(i8* %80, i8* %81)
store i32 %82, i32* %7
%83 = load i32, i32* %7
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %103
85: ; preds = %79
store i32 0, i32* %8
br label %86
86: ; preds = %97, %85
%87 = load i32, i32* %8
%88 = icmp ult i32 %87, 13312
br i1 %88, label %89, label %100
89: ; preds = %86
%90 = load i32, i32* %4
%91 = load i32, i32* %8
%92 = load i32, i32* %8
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds [13312 x i8], [13312 x i8]* %5, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = call i32 @putInMemory(i32 %90, i32 %91, i8 signext %95)
br label %97
97: ; preds = %89
%98 = load i32, i32* %8
%99 = add i32 %98, 1
store i32 %99, i32* %8
br label %86
100: ; preds = %86
%101 = load i32, i32* %4
%102 = call i32 @launchProgram(i32 %101)
br label %103
103: ; preds = %12, %59, %100, %79
ret void
}

LLVM IR (-O2):
define void @executeProgram(i8* %0, i32 %1) {
%3 = alloca [13312 x i8]
%4 = alloca [35 x i8]
%5 = getelementptr inbounds [13312 x i8], [13312 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [35 x i8], [35 x i8]* %4, i64 0, i64 0
%7 = tail call i64 @mod(i32 %1, i32 4096)
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = bitcast [35 x i8]* %4 to <16 x i8>*
store <16 x i8> <i8 83, i8 101, i8 103, i8 109, i8 101, i8 110, i8 116, i8 32, i8 110, i8 111, i8 116, i8 32, i8 97, i8 32, i8 109, i8 117>, <16 x i8>* %10
%11 = getelementptr inbounds [35 x i8], [35 x i8]* %4, i64 0, i64 16
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 108, i8 116, i8 105, i8 112, i8 108, i8 101, i8 32, i8 111, i8 102, i8 32, i8 48, i8 120, i8 49, i8 48, i8 48, i8 48>, <16 x i8>* %12
%13 = getelementptr inbounds [35 x i8], [35 x i8]* %4, i64 0, i64 32
store i8 13, i8* %13
%14 = getelementptr inbounds [35 x i8], [35 x i8]* %4, i64 0, i64 33
store i8 10, i8* %14
%15 = getelementptr inbounds [35 x i8], [35 x i8]* %4, i64 0, i64 34
store i8 0, i8* %15
%16 = call i32 @printString(i8* %6)
br label %38
17: ; preds = %2
%18 = and i32 %1, -4097
%19 = icmp eq i32 %18, 0
%20 = icmp sgt i32 %1, 40960
%21 = or i1 %20, %19
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = bitcast [35 x i8]* %4 to <16 x i8>*
store <16 x i8> <i8 73, i8 108, i8 108, i8 101, i8 103, i8 97, i8 108, i8 32, i8 115, i8 101, i8 103, i8 109, i8 101, i8 110, i8 116, i8 0>, <16 x i8>* %23
%24 = call i32 @printString(i8* %6)
br label %38
25: ; preds = %17
%26 = call i32 @readFile(i8* %0, i8* %5)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25, %28
%29 = phi i64 [ %34, %28 ], [ 0, %25 ]
%30 = getelementptr inbounds [13312 x i8], [13312 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = trunc i64 %29 to i32
%33 = call i32 @putInMemory(i32 %1, i32 %32, i8 signext %31)
%34 = add nuw nsw i64 %29, 1
%35 = icmp eq i64 %34, 13312
br i1 %35, label %36, label %28
36: ; preds = %28
%37 = call i32 @launchProgram(i32 %1)
br label %38
38: ; preds = %25, %36, %22, %9
ret void
}