#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];
  int result;
  unsigned int i;
  if (mod(segment, 0x1000) != 0) {
    char errorMsg[35];
    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) {
    char errorMsg[16];
    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,-0x3450(%rbp)
movb   $0x6c,-0x344f(%rbp)
movb   $0x6c,-0x344e(%rbp)
movb   $0x65,-0x344d(%rbp)
movb   $0x67,-0x344c(%rbp)
movb   $0x61,-0x344b(%rbp)
movb   $0x6c,-0x344a(%rbp)
movb   $0x20,-0x3449(%rbp)
movb   $0x73,-0x3448(%rbp)
movb   $0x65,-0x3447(%rbp)
movb   $0x67,-0x3446(%rbp)
movb   $0x6d,-0x3445(%rbp)
movb   $0x65,-0x3444(%rbp)
movb   $0x6e,-0x3443(%rbp)
movb   $0x74,-0x3442(%rbp)
movb   $0x0,-0x3441(%rbp)
lea    -0x3450(%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,-0x3414(%rbp)
cmpl   $0x0,-0x3414(%rbp)
jne    139e <executeProgram+0x24e>
movl   $0x0,-0x3418(%rbp)
cmpl   $0x3400,-0x3418(%rbp)
jae    1396 <executeProgram+0x246>
mov    -0xc(%rbp),%edi
mov    -0x3418(%rbp),%esi
mov    -0x3418(%rbp),%eax
movsbl -0x3410(%rbp,%rax,1),%edx
ff
call   1040 <putInMemory@plt>
mov    -0x3418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3418(%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 i32
%7 = alloca i32
%8 = alloca [35 x i8]
%9 = alloca [16 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = call i64 @mod(i32 %10, i32 4096)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %51
13: ; preds = %2
%14 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 0
store i8 83, i8* %14
%15 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 1
store i8 101, i8* %15
%16 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 2
store i8 103, i8* %16
%17 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 3
store i8 109, i8* %17
%18 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 4
store i8 101, i8* %18
%19 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 5
store i8 110, i8* %19
%20 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 6
store i8 116, i8* %20
%21 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 7
store i8 32, i8* %21
%22 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 8
store i8 110, i8* %22
%23 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 9
store i8 111, i8* %23
%24 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 10
store i8 116, i8* %24
%25 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 11
store i8 32, i8* %25
%26 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 12
store i8 97, i8* %26
%27 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 13
store i8 32, i8* %27
%28 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 14
store i8 109, i8* %28
%29 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 15
store i8 117, i8* %29
%30 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 16
store i8 108, i8* %30
%31 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 17
store i8 116, i8* %31
%32 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 18
store i8 105, i8* %32
%33 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 19
store i8 112, i8* %33
%34 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 20
store i8 108, i8* %34
%35 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 21
store i8 101, i8* %35
%36 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 22
store i8 32, i8* %36
%37 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 23
store i8 111, i8* %37
%38 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 24
store i8 102, i8* %38
%39 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 25
store i8 32, i8* %39
%40 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 26
store i8 48, i8* %40
%41 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 27
store i8 120, i8* %41
%42 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 28
store i8 49, i8* %42
%43 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 29
store i8 48, i8* %43
%44 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 30
store i8 48, i8* %44
%45 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 31
store i8 48, i8* %45
%46 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 32
store i8 13, i8* %46
%47 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 33
store i8 10, i8* %47
%48 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 34
store i8 0, i8* %48
%49 = getelementptr inbounds [35 x i8], [35 x i8]* %8, i64 0, i64 0
%50 = call i32 @printString(i8* %49)
br label %104
51: ; preds = %2
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %51
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 4096
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* %4
%59 = icmp sgt i32 %58, 40960
br i1 %59, label %60, label %79
60: ; preds = %57, %54, %51
%61 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
store i8 73, i8* %61
%62 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 1
store i8 108, i8* %62
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 2
store i8 108, i8* %63
%64 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 3
store i8 101, i8* %64
%65 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 4
store i8 103, i8* %65
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 5
store i8 97, i8* %66
%67 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 6
store i8 108, i8* %67
%68 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 7
store i8 32, i8* %68
%69 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 8
store i8 115, i8* %69
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 9
store i8 101, i8* %70
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 10
store i8 103, i8* %71
%72 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 11
store i8 109, i8* %72
%73 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 12
store i8 101, i8* %73
%74 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 13
store i8 110, i8* %74
%75 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 14
store i8 116, i8* %75
%76 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 15
store i8 0, i8* %76
%77 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%78 = call i32 @printString(i8* %77)
br label %104
79: ; preds = %57
br label %80
80: ; preds = %79
%81 = load i8*, i8** %3
%82 = getelementptr inbounds [13312 x i8], [13312 x i8]* %5, i64 0, i64 0
%83 = call i32 @readFile(i8* %81, i8* %82)
store i32 %83, i32* %6
%84 = load i32, i32* %6
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %104
86: ; preds = %80
store i32 0, i32* %7
br label %87
87: ; preds = %98, %86
%88 = load i32, i32* %7
%89 = icmp ult i32 %88, 13312
br i1 %89, label %90, label %101
90: ; preds = %87
%91 = load i32, i32* %4
%92 = load i32, i32* %7
%93 = load i32, i32* %7
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds [13312 x i8], [13312 x i8]* %5, i64 0, i64 %94
%96 = load i8, i8* %95
%97 = call i32 @putInMemory(i32 %91, i32 %92, i8 signext %96)
br label %98
98: ; preds = %90
%99 = load i32, i32* %7
%100 = add i32 %99, 1
store i32 %100, i32* %7
br label %87
101: ; preds = %87
%102 = load i32, i32* %4
%103 = call i32 @launchProgram(i32 %102)
br label %104
104: ; preds = %13, %60, %101, %80
ret void
}

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