#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 */
struct process {
  int dummy;
};

/* Variables and functions */
int create_process_list_from_file(char *, struct process **);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_process_list(struct process *);
int /*<<< orphan*/ schedule_rr(struct process **, struct process **);
int main() {
  struct process *completed_head = NULL;
  struct process *active_head = NULL;
  int ret = create_process_list_from_file("all_processes.txt", &active_head);
  if (ret != 0)
    perror("Create process list");
  while (active_head != NULL) {
    schedule_rr(&active_head, &completed_head);
  }
  print_process_list(completed_head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <create_process_list_from_file@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1188 <main+0x48>
lea    0xe8f(%rip),%rdi
call   1060 <perror@plt>
jmp    118d <main+0x4d>
cmpq   $0x0,-0x18(%rbp)
je     11aa <main+0x6a>
lea    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <schedule_rr@plt>
jmp    118d <main+0x4d>
mov    -0x10(%rbp),%rdi
call   1040 <print_process_list@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xea0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <create_process_list_from_file@plt>
test   %eax,%eax
jne    119a <main+0x5a>
cmpq   $0x0,0x8(%rsp)
je     11ae <main+0x6e>
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <schedule_rr@plt>
cmpq   $0x0,0x8(%rsp)
jne    1180 <main+0x40>
mov    0x10(%rsp),%rdi
jmp    11b0 <main+0x70>
lea    0xe71(%rip),%rdi
call   1060 <perror@plt>
cmpq   $0x0,0x8(%rsp)
jne    1176 <main+0x36>
xor    %edi,%edi
call   1040 <print_process_list@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.process = type { i32 }
@.str = [18 x i8] c"all_processes.txt\00"
@.str.1 = [20 x i8] c"Create process list\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.process*
%3 = alloca %struct.process*
%4 = alloca i32
store i32 0, i32* %1
store %struct.process* null, %struct.process** %2
store %struct.process* null, %struct.process** %3
%5 = call i32 @create_process_list_from_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.process** %3)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
br label %11
11: ; preds = %14, %10
%12 = load %struct.process*, %struct.process** %3
%13 = icmp ne %struct.process* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @schedule_rr(%struct.process** %3, %struct.process** %2)
br label %11
16: ; preds = %11
%17 = load %struct.process*, %struct.process** %2
%18 = call i32 @print_process_list(%struct.process* %17)
ret i32 0
}

LLVM IR (-O2):
%struct.process = type { i32 }
@.str = [18 x i8] c"all_processes.txt\00"
@.str.1 = [20 x i8] c"Create process list\00"
define i32 @main() {
%1 = alloca %struct.process*
%2 = alloca %struct.process*
%3 = bitcast %struct.process** %1 to i8*
store %struct.process* null, %struct.process** %1
%4 = bitcast %struct.process** %2 to i8*
store %struct.process* null, %struct.process** %2
%5 = call i32 @create_process_list_from_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.process** %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load %struct.process*, %struct.process** %2
%11 = icmp eq %struct.process* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9, %12
%13 = call i32 @schedule_rr(%struct.process** %2, %struct.process** %1)
%14 = load %struct.process*, %struct.process** %2
%15 = icmp eq %struct.process* %14, null
br i1 %15, label %16, label %12
16: ; preds = %12
%17 = load %struct.process*, %struct.process** %1
br label %18
18: ; preds = %16, %9
%19 = phi %struct.process* [ %17, %16 ], [ null, %9 ]
%20 = call i32 @print_process_list(%struct.process* %19)
ret i32 0
}