#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 auth_get_c_id();
char *auth_get_company();
int auth_get_s_id();
char *auth_get_username();
int /*<<< orphan*/ auth_login_procedure();
int /*<<< orphan*/ command_dispatcher(char const *);
int /*<<< orphan*/ printf(char *);
char *prl_gets();
int /*<<< orphan*/ prl_set_prompt(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, int, int);
int main(int argc, char *argv[]) {
  printf("BilliT version 0.2\n");
  printf("Copyright (C) 2016 Parham Alvani (parham.alvani@gmail.com)\n");
  printf(
      "BilliT comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n");
  printf("This is free software, and you are welcome to redistribute it\n");
  printf("under certain conditions; type `show c' for details.\n");
  printf("\n");
  auth_login_procedure();
  const char *command;
  char prompt[1024];
  while (true) {
    sprintf(prompt, "%s @ BilliC {%s} [%d, %d] $ ", auth_get_username(),
            auth_get_company(), auth_get_s_id(), auth_get_c_id());
    prl_set_prompt(prompt);
    command = prl_gets();
    command_dispatcher(command);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe40(%rip),%rdi
call   1080 <printf@plt>
lea    0xe48(%rip),%rdi
call   1080 <printf@plt>
lea    0xe78(%rip),%rdi
call   1080 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1080 <printf@plt>
lea    0xee5(%rip),%rdi
call   1080 <printf@plt>
lea    0xe52(%rip),%rdi
call   1080 <printf@plt>
mov    $0x0,%al
call   1030 <auth_login_procedure@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x440(%rbp)
mov    $0x0,%al
call   10a0 <auth_get_username@plt>
mov    %rax,-0x438(%rbp)
mov    $0x0,%al
call   10b0 <auth_get_company@plt>
mov    %rax,-0x430(%rbp)
mov    $0x0,%al
call   1070 <auth_get_s_id@plt>
mov    %eax,-0x424(%rbp)
mov    $0x0,%al
call   1090 <auth_get_c_id@plt>
mov    -0x440(%rbp),%rdi
mov    -0x438(%rbp),%rdx
mov    -0x430(%rbp),%rcx
mov    -0x424(%rbp),%r8d
mov    %eax,%r9d
lea    0xe9f(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <prl_set_prompt@plt>
mov    $0x0,%al
call   1050 <prl_gets@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <command_dispatcher@plt>
jmp    1208 <main+0x68>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xef8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <auth_login_procedure@plt>
lea    0xded(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <auth_get_username@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10c0 <auth_get_company@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <auth_get_s_id@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <auth_get_c_id@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %eax,%r9d
call   10d0 <sprintf@plt>
mov    %r15,%rdi
call   1060 <prl_set_prompt@plt>
xor    %eax,%eax
call   1070 <prl_gets@plt>
mov    %rax,%rdi
call   1080 <command_dispatcher@plt>
jmp    1220 <main+0x70>

LLVM IR (-O0):
@.str = [20 x i8] c"BilliT version 0.2\0A\00"
@.str.1 = [60 x i8] c"Copyright (C) 2016 Parham Alvani (parham.alvani@gmail.com)\0A\00"
@.str.2 = [70 x i8] c"BilliT comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\0A\00"
@.str.3 = [63 x i8] c"This is free software, and you are welcome to redistribute it\0A\00"
@.str.4 = [54 x i8] c"under certain conditions; type `show c' for details.\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [29 x i8] c"%s @ BilliC {%s} [%d, %d] $ \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (...) @auth_login_procedure()
br label %15
15: ; preds = %2, %15
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = call i8* (...) @auth_get_username()
%18 = call i8* (...) @auth_get_company()
%19 = call i32 (...) @auth_get_s_id()
%20 = call i32 (...) @auth_get_c_id()
%21 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %17, i8* %18, i32 %19, i32 %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%23 = call i32 @prl_set_prompt(i8* %22)
%24 = call i8* (...) @prl_gets()
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i32 @command_dispatcher(i8* %25)
br label %15
}

LLVM IR (-O2):
@.str.6 = [29 x i8] c"%s @ BilliC {%s} [%d, %d] $ \00"
@str = [19 x i8] c"BilliT version 0.2\00"
@str.7 = [59 x i8] c"Copyright (C) 2016 Parham Alvani (parham.alvani@gmail.com)\00"
@str.8 = [69 x i8] c"BilliT comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\00"
@str.9 = [62 x i8] c"This is free software, and you are welcome to redistribute it\00"
@str.10 = [53 x i8] c"under certain conditions; type `show c' for details.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.8, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 (...) @auth_login_procedure()
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
br label %12
12: ; preds = %12, %2
%13 = call i8* (...) @auth_get_username()
%14 = call i8* (...) @auth_get_company()
%15 = call i32 (...) @auth_get_s_id()
%16 = call i32 (...) @auth_get_c_id()
%17 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %13, i8* %14, i32 %15, i32 %16)
%18 = call i32 @prl_set_prompt(i8* %11)
%19 = call i8* (...) @prl_gets()
%20 = call i32 @command_dispatcher(i8* %19)
br label %12
}