#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*/ init_memory();
int /*<<< orphan*/ load_program(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void initialize(char *program_filename, int num_prog_files, char *pc_filename) {
  int i;
  init_memory();
  for (i = 0; i < num_prog_files; i++) {
    printf("Loading %s\n", program_filename);
    load_program(program_filename, pc_filename);
    while (*program_filename++ != '\0')
      ;
  }
  printf("Init done\n");
}


x86 assembly (clang, -O0):
<initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <init_memory@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <initialize+0x7f>
mov    -0x8(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <load_program@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119c <initialize+0x6c>
jmp    117c <initialize+0x4c>
jmp    11a1 <initialize+0x71>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <initialize+0x21>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <init_memory@plt>
test   %r12d,%r12d
jle    11a1 <initialize+0x61>
lea    0xe9c(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <load_program@plt>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1190 <initialize+0x50>
add    $0x1,%ebp
cmp    %r12d,%ebp
jne    1170 <initialize+0x30>
lea    0xe64(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Loading %s\0A\00"
@.str.1 = [11 x i8] c"Init done\0A\00"
define void @initialize(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = call i32 (...) @init_memory()
store i32 0, i32* %7
br label %9
9: ; preds = %27, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = load i8*, i8** %6
%18 = call i32 @load_program(i8* %16, i8* %17)
br label %19
19: ; preds = %25, %13
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = load i8, i8* %20
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
br label %19
26: ; preds = %19
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %9
30: ; preds = %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Loading %s\0A\00"
@str = [10 x i8] c"Init done\00"
define void @initialize(i8* %0, i32 %1, i8* %2) {
%4 = tail call i32 (...) @init_memory()
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %19
6: ; preds = %3, %16
%7 = phi i32 [ %17, %16 ], [ 0, %3 ]
%8 = phi i8* [ %13, %16 ], [ %0, %3 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @load_program(i8* %8, i8* %2)
br label %11
11: ; preds = %11, %6
%12 = phi i8* [ %8, %6 ], [ %13, %11 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %11
16: ; preds = %11
%17 = add nuw nsw i32 %7, 1
%18 = icmp eq i32 %17, %1
br i1 %18, label %19, label %6
19: ; preds = %16, %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
ret void
}