#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*/ assert(char *);
int config(int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
char *strcat(char *, char *);
char *strncat(char *, char *, int);
int /*<<< orphan*/ system(char *);
void startup(char *uname, char *hostname, char *password, int profileExists) {
  int callKeygen = 0;
  callKeygen = config(callKeygen);
  if (callKeygen == 0) {
    printf("Creating keys...\n");
    system("./.scripts/.ssh-keygen > /dev/null");
  }
  if (profileExists == 0) {
    char *path = "./.scripts/.copyKey ";
    char *null = " > /dev/null";
    char *space = " ";
    char *cmd = malloc(200);
    assert(cmd);
    cmd[0] = '\0';
    cmd = strcat(cmd, path);
    cmd = strncat(cmd, uname, 30);
    cmd = strcat(cmd, space);
    cmd = strncat(cmd, hostname, 50);
    cmd = strcat(cmd, space);
    cmd = strncat(cmd, password, 100);
    cmd = strcat(cmd, null);
    printf("Copying key to destination...\n");
    system(cmd);
    free(cmd);
  }
  system("clear");
}


x86 assembly (clang, -O0):
<startup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1090 <config@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11cb <startup+0x4b>
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4c(%rip),%rdi
call   1040 <system@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12b8 <startup+0x138>
lea    0xe59(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe41(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe56(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    $0xc8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x1e,%edx
call   1060 <strncat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x32,%edx
call   1060 <strncat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x64,%edx
call   1060 <strncat@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %rax,-0x40(%rbp)
lea    0xda9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <system@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
lea    0xdaa(%rip),%rdi
call   1040 <system@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
call   10a0 <config@plt>
test   %eax,%eax
je     11b7 <startup+0x37>
test   %ebp,%ebp
je     11d3 <startup+0x53>
lea    0xe90(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <system@plt>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe36(%rip),%rdi
call   1060 <system@plt>
test   %ebp,%ebp
jne    11a1 <startup+0x21>
mov    $0xc8,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <assert@plt>
movb   $0x0,0x0(%rbp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
movabs $0x2079654b79706f,%rcx
mov    %rcx,0xd(%rbp,%rax,1)
movups 0xe19(%rip),%xmm0
movups %xmm0,0x0(%rbp,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1e,%edx
call   1070 <strncat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
movw   $0x20,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x32,%edx
call   1070 <strncat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
movw   $0x20,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1070 <strncat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
movabs $0x2f7665642f203e20,%rcx
65 76 2f
mov    %rcx,(%rbx,%rax,1)
movabs $0x6c6c756e2f7665,%rcx
mov    %rcx,0x5(%rbx,%rax,1)
lea    0xdae(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11a1 <startup+0x21>

LLVM IR (-O0):
@.str = [18 x i8] c"Creating keys...\0A\00"
@.str.1 = [35 x i8] c"./.scripts/.ssh-keygen > /dev/null\00"
@.str.2 = [21 x i8] c"./.scripts/.copyKey \00"
@.str.3 = [13 x i8] c" > /dev/null\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [31 x i8] c"Copying key to destination...\0A\00"
@.str.6 = [6 x i8] c"clear\00"
define void @startup(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %9
%14 = load i32, i32* %9
%15 = call i32 @config(i32 %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %4
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %56
24: ; preds = %21
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %12
%25 = call i8* @malloc(i32 200)
store i8* %25, i8** %13
%26 = load i8*, i8** %13
%27 = call i32 @assert(i8* %26)
%28 = load i8*, i8** %13
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 0, i8* %29
%30 = load i8*, i8** %13
%31 = load i8*, i8** %10
%32 = call i8* @strcat(i8* %30, i8* %31)
store i8* %32, i8** %13
%33 = load i8*, i8** %13
%34 = load i8*, i8** %5
%35 = call i8* @strncat(i8* %33, i8* %34, i32 30)
store i8* %35, i8** %13
%36 = load i8*, i8** %13
%37 = load i8*, i8** %12
%38 = call i8* @strcat(i8* %36, i8* %37)
store i8* %38, i8** %13
%39 = load i8*, i8** %13
%40 = load i8*, i8** %6
%41 = call i8* @strncat(i8* %39, i8* %40, i32 50)
store i8* %41, i8** %13
%42 = load i8*, i8** %13
%43 = load i8*, i8** %12
%44 = call i8* @strcat(i8* %42, i8* %43)
store i8* %44, i8** %13
%45 = load i8*, i8** %13
%46 = load i8*, i8** %7
%47 = call i8* @strncat(i8* %45, i8* %46, i32 100)
store i8* %47, i8** %13
%48 = load i8*, i8** %13
%49 = load i8*, i8** %11
%50 = call i8* @strcat(i8* %48, i8* %49)
store i8* %50, i8** %13
%51 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%52 = load i8*, i8** %13
%53 = call i32 @system(i8* %52)
%54 = load i8*, i8** %13
%55 = call i32 @free(i8* %54)
br label %56
56: ; preds = %24, %21
%57 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"./.scripts/.ssh-keygen > /dev/null\00"
@.str.2 = [21 x i8] c"./.scripts/.copyKey \00"
@.str.3 = [13 x i8] c" > /dev/null\00"
@.str.6 = [6 x i8] c"clear\00"
@str = [30 x i8] c"Copying key to destination...\00"
@str.7 = [17 x i8] c"Creating keys...\00"
define void @startup(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @config(i32 0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %7, %4
%11 = icmp eq i32 %3, 0
br i1 %11, label %12, label %31
12: ; preds = %10
%13 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%14 = tail call i32 @assert(i8* %13)
store i8 0, i8* %13
%15 = tail call i64 @strlen(i8* %13)
%16 = getelementptr i8, i8* %13, i64 %15
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(21) %16, i8* align 1 dereferenceable(21) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 21, i1 false)
%17 = tail call i8* @strncat(i8* %13, i8* %0, i32 30)
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = getelementptr i8, i8* %17, i64 %18
%20 = bitcast i8* %19 to i16*
store i16 32, i16* %20
%21 = tail call i8* @strncat(i8* %17, i8* %1, i32 50)
%22 = tail call i64 @strlen(i8* dereferenceable(1) %21)
%23 = getelementptr i8, i8* %21, i64 %22
%24 = bitcast i8* %23 to i16*
store i16 32, i16* %24
%25 = tail call i8* @strncat(i8* %21, i8* %2, i32 100)
%26 = tail call i64 @strlen(i8* dereferenceable(1) %25)
%27 = getelementptr i8, i8* %25, i64 %26
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %27, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 13, i1 false)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @system(i8* %25)
%30 = tail call i32 @free(i8* %25)
br label %31
31: ; preds = %12, %10
%32 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}