#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*/ exit(int);
int /*<<< orphan*/ loginUser(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ registerUser(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char *host;
  int type;
  if (argc < 2) {
    printf("Command Options: %s server host\n", argv[0]);
    exit(1);
  }
  host = argv[1];
  while (type != 3) {
    system("clear");
    printf("Welcome !!!\n");
    printf("1. Register\n");
    printf("2. Login\n");
    printf("3. Quit\n");
    printf("Enter Choice: ");
    scanf("%d", &type);
    switch (type) {
    case 1:
      registerUser(host);
      break;
    case 2:
      loginUser(host);
      break;
    case 3:
      break;
    default:
      printf("Invalid Option\n");
      type = 3;
      break;
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x1c(%rbp)
je     128f <main+0x12f>
lea    0xe65(%rip),%rdi
call   1040 <system@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1050 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     1254 <main+0xf4>
jmp    1232 <main+0xd2>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     1262 <main+0x102>
jmp    1243 <main+0xe3>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     1270 <main+0x110>
jmp    1275 <main+0x115>
mov    -0x18(%rbp),%rdi
call   1030 <registerUser@plt>
jmp    128a <main+0x12a>
mov    -0x18(%rbp),%rdi
call   1060 <loginUser@plt>
jmp    128a <main+0x12a>
jmp    128a <main+0x12a>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x3,-0x1c(%rbp)
jmp    11ab <main+0x4b>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     119b <main+0x2b>
mov    (%rsi),%rsi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x8(%rsi),%rbx
lea    0xeab(%rip),%r13
lea    0xead(%rip),%rbp
lea    0xe73(%rip),%r14
lea    0xe7b(%rip),%r15
lea    0x4(%rsp),%r12
jmp    11df <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <registerUser@plt>
cmpl   $0x3,0x4(%rsp)
je     124c <main+0xdc>
lea    0xe3b(%rip),%rdi
call   1050 <system@plt>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     11d0 <main+0x60>
cmp    $0x2,%eax
jne    1247 <main+0xd7>
mov    %rbx,%rdi
call   1070 <loginUser@plt>
cmpl   $0x3,0x4(%rsp)
jne    11df <main+0x6f>
jmp    124c <main+0xdc>
cmp    $0x3,%eax
jne    1253 <main+0xe3>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
movl   $0x3,0x4(%rsp)
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Command Options: %s server host\0A\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [13 x i8] c"Welcome !!!\0A\00"
@.str.3 = [13 x i8] c"1. Register\0A\00"
@.str.4 = [10 x i8] c"2. Login\0A\00"
@.str.5 = [9 x i8] c"3. Quit\0A\00"
@.str.6 = [15 x i8] c"Enter Choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [16 x i8] c"Invalid Option\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
br label %20
20: ; preds = %41, %16
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %42
23: ; preds = %20
%24 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%31 = load i32, i32* %7
switch i32 %31, label %39 [
i32 1, label %32
i32 2, label %35
i32 3, label %38
]
32: ; preds = %23
%33 = load i8*, i8** %6
%34 = call i32 @registerUser(i8* %33)
br label %41
35: ; preds = %23
%36 = load i8*, i8** %6
%37 = call i32 @loginUser(i8* %36)
br label %41
38: ; preds = %23
br label %41
39: ; preds = %23
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
store i32 3, i32* %7
br label %41
41: ; preds = %39, %38, %35, %32
br label %20
42: ; preds = %20
%43 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [33 x i8] c"Command Options: %s server host\0A\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.6 = [15 x i8] c"Enter Choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@str = [12 x i8] c"Welcome !!!\00"
@str.9 = [12 x i8] c"1. Register\00"
@str.10 = [9 x i8] c"2. Login\00"
@str.11 = [8 x i8] c"3. Quit\00"
@str.12 = [15 x i8] c"Invalid Option\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
br label %13
13: ; preds = %10, %28
%14 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
switch i32 %21, label %26 [
i32 1, label %22
i32 2, label %24
i32 3, label %31
]
22: ; preds = %13
%23 = call i32 @registerUser(i8* %12)
br label %28
24: ; preds = %13
%25 = call i32 @loginUser(i8* %12)
br label %28
26: ; preds = %13
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0))
store i32 3, i32* %3
br label %31
28: ; preds = %24, %22
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %13
31: ; preds = %13, %28, %26
%32 = call i32 @exit(i32 0)
unreachable
}