#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ safePrefWrite(int, char *);
int /*<<< orphan*/ safeRead(int, int *, int);
int /*<<< orphan*/ safeStdinRead(char *, char *, int);
int /*<<< orphan*/ userPrints(int, char *);
void viewProfile(int sC) {
  int resultAnswer = -1;
  char user[33];
  memset(user, 0, 33);
  safeStdinRead("View profile of user:", user, 33);
  safePrefWrite(sC, user);
  safeRead(sC, &resultAnswer, sizeof(int));
  switch (resultAnswer) {
  case 401:
    printf("User doesn't exist in our database or is invalid !\n");
    break;
  case 402:
    printf("This user is private ! Please login or register !\n");
    break;
  case 441:
    printf("\033[31m"
           "\nYou're not logged in ! \n"
           "\033[0m");
    userPrints(sC, user);
    break;
  case 442:
    printf("\033[33m"
           "\nYou're not friend with '%s' !\n"
           "\033[0m",
           user);
    userPrints(sC, user);
    break;
  case 443:
  case 444:
    userPrints(sC, user);
    break;
  case 445:
    printf("\nIt's you !\n");
    userPrints(sC, user);
    break;
  default:
    printf("ERROR !\n");
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<viewProfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    %rdi,-0x40(%rbp)
xor    %esi,%esi
mov    $0x21,%edx
mov    %edx,-0x44(%rbp)
call   1050 <memset@plt>
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%rsi
lea    0xf1d(%rip),%rdi
call   1060 <safeStdinRead@plt>
mov    -0x40(%rbp),%rsi
mov    -0x4(%rbp),%edi
call   1030 <safePrefWrite@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1080 <safeRead@plt>
mov    -0x8(%rbp),%eax
add    $0xfffffe6f,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x2c,%eax
ja     127c <viewProfile+0x11c>
mov    -0x38(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128a <viewProfile+0x12a>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128a <viewProfile+0x12a>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <userPrints@plt>
jmp    128a <viewProfile+0x12a>
lea    -0x30(%rbp),%rsi
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <userPrints@plt>
jmp    128a <viewProfile+0x12a>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <userPrints@plt>
jmp    128a <viewProfile+0x12a>
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <userPrints@plt>
jmp    128a <viewProfile+0x12a>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<viewProfile>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1060 <memset@plt>
lea    0xf19(%rip),%rdi
mov    %rbx,%rsi
mov    $0x21,%edx
call   1070 <safeStdinRead@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <safePrefWrite@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1090 <safeRead@plt>
mov    $0xfffffe6f,%eax
add    0xc(%rsp),%eax
cmp    $0x2c,%eax
ja     11f3 <viewProfile+0x83>
lea    0xe28(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf6c(%rip),%rdi
jmp    11fa <viewProfile+0x8a>
lea    0xf31(%rip),%rdi
jmp    11fa <viewProfile+0x8a>
lea    0xf8d(%rip),%rdi
call   1030 <puts@plt>
jmp    1246 <viewProfile+0xd6>
lea    0xee5(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
jmp    1241 <viewProfile+0xd1>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
jmp    123a <viewProfile+0xca>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
call   1080 <userPrints@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"View profile of user:\00"
@.str.1 = [52 x i8] c"User doesn't exist in our database or is invalid !\0A\00"
@.str.2 = [51 x i8] c"This user is private ! Please login or register !\0A\00"
@.str.3 = [35 x i8] c"\1B[31m\0AYou're not logged in ! \0A\1B[0m\00"
@.str.4 = [41 x i8] c"\1B[33m\0AYou're not friend with '%s' !\0A\1B[0m\00"
@.str.5 = [13 x i8] c"\0AIt's you !\0A\00"
@.str.6 = [9 x i8] c"ERROR !\0A\00"
define void @viewProfile(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [33 x i8]
store i32 %0, i32* %2
store i32 -1, i32* %3
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 33)
%7 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%8 = call i32 @safeStdinRead(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %7, i32 33)
%9 = load i32, i32* %2
%10 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%11 = call i32 @safePrefWrite(i32 %9, i8* %10)
%12 = load i32, i32* %2
%13 = call i32 @safeRead(i32 %12, i32* %3, i32 4)
%14 = load i32, i32* %3
switch i32 %14, label %39 [
i32 401, label %15
i32 402, label %17
i32 441, label %19
i32 442, label %24
i32 443, label %30
i32 444, label %30
i32 445, label %34
]
15: ; preds = %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %41
17: ; preds = %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %41
19: ; preds = %1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%23 = call i32 @userPrints(i32 %21, i8* %22)
br label %41
24: ; preds = %1
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %2
%28 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%29 = call i32 @userPrints(i32 %27, i8* %28)
br label %41
30: ; preds = %1, %1
%31 = load i32, i32* %2
%32 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%33 = call i32 @userPrints(i32 %31, i8* %32)
br label %41
34: ; preds = %1
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* %2
%37 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%38 = call i32 @userPrints(i32 %36, i8* %37)
br label %41
39: ; preds = %1
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %39, %34, %30, %24, %19, %17, %15
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"View profile of user:\00"
@.str.3 = [35 x i8] c"\1B[31m\0AYou're not logged in ! \0A\1B[0m\00"
@.str.4 = [41 x i8] c"\1B[33m\0AYou're not friend with '%s' !\0A\1B[0m\00"
@str = [12 x i8] c"\0AIt's you !\00"
@str.7 = [50 x i8] c"This user is private ! Please login or register !\00"
@str.8 = [51 x i8] c"User doesn't exist in our database or is invalid !\00"
@str.9 = [8 x i8] c"ERROR !\00"
define void @viewProfile(i32 %0) {
%2 = alloca i32
%3 = alloca [33 x i8]
%4 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 33)
%7 = call i32 @safeStdinRead(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5, i32 33)
%8 = call i32 @safePrefWrite(i32 %0, i8* %5)
%9 = call i32 @safeRead(i32 %0, i32* %2, i32 4)
%10 = load i32, i32* %2
switch i32 %10, label %26 [
i32 401, label %11
i32 402, label %13
i32 441, label %15
i32 442, label %18
i32 443, label %21
i32 444, label %21
i32 445, label %23
]
11: ; preds = %1
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.8, i64 0, i64 0))
br label %28
13: ; preds = %1
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.7, i64 0, i64 0))
br label %28
15: ; preds = %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @userPrints(i32 %0, i8* %5)
br label %28
18: ; preds = %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%20 = call i32 @userPrints(i32 %0, i8* %5)
br label %28
21: ; preds = %1, %1
%22 = call i32 @userPrints(i32 %0, i8* %5)
br label %28
23: ; preds = %1
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%25 = call i32 @userPrints(i32 %0, i8* %5)
br label %28
26: ; preds = %1
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
br label %28
28: ; preds = %26, %23, %21, %18, %15, %13, %11
ret void
}