#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*/ gdt_set(int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ terminal_writestring(char *);
void gdt_install() {
  terminal_writestring("--------Init GDT--------\n");
  gdt_set(0, 0, 0, 0);
  terminal_writestring("GDT Initialized with Null Pointer\n");
  gdt_set(1, 0, 0xFFFF, 0x9A);
  terminal_writestring("GDT Appended with Code Segment\n");
  gdt_set(2, 0, 0xFFFF, 0x92);
  terminal_writestring("GDT Appended with Data Segment\n");
  terminal_writestring("--------GDT Init GDT_SUCCESS--------\n");
}


x86 assembly (clang, -O0):
<gdt_install>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <terminal_writestring@plt>
xor    %ecx,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1040 <gdt_set@plt>
lea    0xed6(%rip),%rdi
call   1030 <terminal_writestring@plt>
mov    $0x1,%edi
xor    %esi,%esi
mov    $0xffff,%edx
mov    $0x9a,%ecx
call   1040 <gdt_set@plt>
lea    0xed7(%rip),%rdi
call   1030 <terminal_writestring@plt>
mov    $0x2,%edi
xor    %esi,%esi
mov    $0xffff,%edx
mov    $0x92,%ecx
call   1040 <gdt_set@plt>
lea    0xed5(%rip),%rdi
call   1030 <terminal_writestring@plt>
lea    0xee9(%rip),%rdi
call   1030 <terminal_writestring@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdt_install>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <terminal_writestring@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <gdt_set@plt>
lea    0xed9(%rip),%rdi
call   1030 <terminal_writestring@plt>
mov    $0x1,%edi
xor    %esi,%esi
mov    $0xffff,%edx
mov    $0x9a,%ecx
call   1040 <gdt_set@plt>
lea    0xeda(%rip),%rdi
call   1030 <terminal_writestring@plt>
mov    $0x2,%edi
xor    %esi,%esi
mov    $0xffff,%edx
mov    $0x92,%ecx
call   1040 <gdt_set@plt>
lea    0xed8(%rip),%rdi
call   1030 <terminal_writestring@plt>
lea    0xeec(%rip),%rdi
pop    %rax
jmp    1030 <terminal_writestring@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"--------Init GDT--------\0A\00"
@.str.1 = [35 x i8] c"GDT Initialized with Null Pointer\0A\00"
@.str.2 = [32 x i8] c"GDT Appended with Code Segment\0A\00"
@.str.3 = [32 x i8] c"GDT Appended with Data Segment\0A\00"
@.str.4 = [38 x i8] c"--------GDT Init GDT_SUCCESS--------\0A\00"
define void @gdt_install() {
%1 = call i32 @terminal_writestring(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @gdt_set(i32 0, i32 0, i32 0, i32 0)
%3 = call i32 @terminal_writestring(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @gdt_set(i32 1, i32 0, i32 65535, i32 154)
%5 = call i32 @terminal_writestring(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @gdt_set(i32 2, i32 0, i32 65535, i32 146)
%7 = call i32 @terminal_writestring(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @terminal_writestring(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"--------Init GDT--------\0A\00"
@.str.1 = [35 x i8] c"GDT Initialized with Null Pointer\0A\00"
@.str.2 = [32 x i8] c"GDT Appended with Code Segment\0A\00"
@.str.3 = [32 x i8] c"GDT Appended with Data Segment\0A\00"
@.str.4 = [38 x i8] c"--------GDT Init GDT_SUCCESS--------\0A\00"
define void @gdt_install() {
%1 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @gdt_set(i32 0, i32 0, i32 0, i32 0)
%3 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @gdt_set(i32 1, i32 0, i32 65535, i32 154)
%5 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @gdt_set(i32 2, i32 0, i32 65535, i32 146)
%7 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @terminal_writestring(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
ret void
}